X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   periodic bestseller (weekly/monthly/annually) (https://forum.x-cart.com/showthread.php?t=27575)

inebriate 12-24-2006 11:39 PM

periodic bestseller (weekly/monthly/annually)
 
warning: this was not tested on a live server, so please backup your xcart sql database just in case...its actually my first time playing with mysql functions but i have a programming background so was able to catch on

note: this will reset your products' sales stats and obviously you must have both the Advanced Statistics and the Bestsellers modules enabled, also products are not considered 'sold' until the order is 'processed'

in modules/Advanced_Statistics/prod_sold.php, look for
Code:

$avail_condition = "";
if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y")
        $avail_condition = " AND $sql_tbl[products].avail>0 ";

and add below it
Code:

#START MOD
#******************************************************
# PERIODIC BESTSELLER by david@fabric8d
#******************************************************
# d:day
# W:week
# m:month
# Y:year
#--------------
# if you want to use a different period, change what is
# inside the date() function to one of the values above,
# ie: date(m) for monthly.
#
# also if you want to do a bi- or tri- period, multiply
# it in front of the function, ie: 2 * (int)date(W) for
# bi-weekly
#******************************************************
$dateP = (int)date(W);
$dateY = (int)date(Y);
$lastupdateP = (int)func_query_first_cell("SELECT period FROM xcart_lastupdate");
if(abs($dateP-$lastupdateP) > 0)
{
        db_query("UPDATE $sql_tbl[products] SET sales_stats=0");
        db_query("UPDATE xcart_lastupdate SET period=$dateP");
        db_query("UPDATE xcart_lastupdate SET year=$dateY");
}
#END MOD


now in the xcart admin section, goto patch/upgrade...in the "SQL query(ies)" textbox, paste one by one each line (or together, i dont know if it will work though)
Code:

CREATE TABLE `xcart_lastupdate` (`period` INT( 2 ) NOT NULL ,`year` INT( 4 ) NOT NULL)
UPDATE xcart_lastupdate SET week=51
UPDATE xcart_lastupdate SET year=2006

and apply

also, you may want to update the bestseller label (lbl_bestsellers) to reflect the period

that should be it...it should work for 4.0.x and 4.1.x

AJ-UKRS 06-14-2007 11:24 AM

Re: periodic bestseller (weekly/monthly/annually)
 
Will this work on 3.5.x?

AJ-UKRS 06-15-2007 04:57 AM

Re: periodic bestseller (weekly/monthly/annually)
 
anyone that can get this working on 3.5.x?


All times are GMT -8. The time now is 02:33 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.