View Single Post
  #2  
Old 12-08-2008, 01:03 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Set the time period for Bestsellers

As you know the module Advanced statistics is very slowly but it's required for Bestsellers module.
I'd recommend you new method of "real" Bestsellers, based on purchases statistics, not views statistics.
Open file /modules/Bestsellers/bestsellers.php and remove all lines between

Code:
if (!defined('XCART_SESSION_START')) { header("Location: ../../"); die("Access denied"); }
and
Code:
$smarty->assign("bestsellers", $bestsellers);
So insert between these lines next code:
Code:
$tm = time(); if ($cat) $cat_limit = "pc.categoryid = '$cat' and"; if (!$config[Bestsellers][number_of_bestsellers] || $config[Bestsellers][number_of_bestsellers] < 0) $config[Bestsellers][number_of_bestsellers] = 0; $bestsellers = func_query("select distinct p.*, pr.price as taxed_price, (($tm-p.add_date)) as adddate from $sql_tbl[products] p inner join $sql_tbl[products_categories] pc on pc.productid = p.productid left join $sql_tbl[pricing] pr on pr.productid = p.productid where $cat_limit p.forsale='Y' and (($tm-p.add_date)/86400)<3 and p.avail > 0 order by add_date desc limit ".$config[Bestsellers][number_of_bestsellers]);

Currently this code select bestsellers which add less that 3 days. You can change it in query, find (($tm-p.add_date)/86400)<3 and change number 3 to another period in days.

It's fast and effective method of bestsellers' selection without heavy Advanced statistics module enabled and heavy queries used.

I've make small changes without testing so if you will have any problems please don't hesitate to ask any questions.
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote