Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Show x number of "top" selling products in bestsellers list

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 10-03-2006, 12:02 PM
  enge919's Avatar 
enge919 enge919 is offline
 

Senior Member
  
Join Date: May 2003
Posts: 141
 

Default Show x number of "top" selling products in bestsellers list

I have seen several places where people are looking how to change the bestsellers list to just display a certain number of items in the list and NOT be dependent on the category they are in (for example the home page)

I just did this for a client. This is for version 4.1.2
I have not checked to see how this will work in earlier versions but im sure it will work fine in the 4.1.x branch. Basically I am just commenting out some code in the script.

in the root xcart folder find modules/bestsellers.php and either copy this whole file or just comment out the sections found here:

<?php
/************************************************** ***************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2006 Ruslan R. Fazliev <rrf@rrf.ru> |
| All rights reserved. |
+-----------------------------------------------------------------------------+
| PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php |
| |
| THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. |
| FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
| AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
| PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
| CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
| COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
| (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
| LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
| AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
| OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
| THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2006 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\************************************************* ****************************/

#
# $Id: bestsellers.php,v 1.31 2006/01/11 06:56:07 mclap Exp $
#
# Bestsellers
#

if (!defined('XCART_SESSION_START')) { header("Location: ../../"); die("Access denied"); }

x_load('product');

if (!is_numeric($config["Bestsellers"]["number_of_bestsellers"]))
$config["Bestsellers"]["number_of_bestsellers"] = 0;

#
# Get products data for current category and store it into $products array
#
$avail_condition = "";
if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y")
$avail_condition = " AND $sql_tbl[products].avail>0 ";

$cat = intval($cat);
//START COMMENT//
/*if ($cat) {

$category_data = func_query_first("SELECT categoryid_path, threshold_bestsellers FROM $sql_tbl[categories] USE INDEX (PRIMARY) WHERE categoryid='$cat'");
$result = func_query("SELECT categoryid, threshold_bestsellers FROM $sql_tbl[categories] USE INDEX (pa) WHERE categoryid_path LIKE '$category_data[categoryid_path]/%' AND avail='Y'");

$threshold = (int)$category_data["threshold_bestsellers"];

$cat_ids = array();

if (is_array($result)) {
foreach($result as $k=>$v) {
$cat_ids[] = $v["categoryid"];
if ($v["threshold_bestsellers"]>0 && $threshold > $v["threshold_bestsellers"])
$threshold = $v["threshold_bestsellers"];
}
}
else
$cat_ids[] = $cat;

$str = " AND $sql_tbl[products_categories].categoryid IN (".implode(",", $cat_ids).")";

if ($threshold)
$threshold -=1;

$search_query = $str." AND $sql_tbl[products].views_stats>0 AND $sql_tbl[products].sales_stats > $threshold";
}
else {*/
//END COMMENT//
$threshold = 0;
$search_query = " AND $sql_tbl[products].sales_stats>$threshold";
#} //COMMENT CLOSING BRACKET//

$order_by = "$sql_tbl[products].sales_stats DESC, $sql_tbl[products].views_stats DESC";

#
# Search the bestsellers
#
$bestsellers = func_search_products($search_query, @$user_account["membershipid"], $order_by, $config["Bestsellers"]["number_of_bestsellers"]);

$smarty->assign("bestsellers",$bestsellers);

?>

There you have it!
__________________
Web site design - Custom Programming - Upgrades - Marketing
www.netvisionwebdesign.com

Follow on twitter: http://twitter.com/netvisionweb
Become a fan on Facebook: http://www.facebook.com/pages/NetVision-Web-Design/89463493419
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:52 PM.

   

 
X-Cart forums © 2001-2020