InkMagic
VP-CART New User
123 Posts |
Posted - January 24 2013 : 23:03:11
|
Hi There:
I've had my website running for about 10 years now.
When I have 'Top Sellers' showing in the left column, it's pulling up products that we sold 6, 8 or even 10 years ago. We don't even sell these products any more.
Is there a way to force it to show only the top sellers from the last 6 month or year?
Thanks .. Dale |
|
devshb
Senior Member
United Kingdom
1904 Posts |
Posted - January 31 2013 : 20:03:01
|
first you need to configure your "x" days-ago value somewhere, the easiest way to do that is to just add something like this to your customer-side shop$config.asp file:
Dim xbyz_cus_topsellers_max_days_ago xbyz_cus_topsellers_max_days_ago=180
then, you need to change the queries that the top-sellers stuff uses so that it uses your new config option (if it's not blank), to do that, edit shopproductsubs.asp in notepad (back it up first!), and there are 2 functions that you need to change:
inside shopproductsubs.asp, search for:
sub NavigateTopTen
*AND* :
sub NavigateTopSeller
and within those functions, you need to force a join back to the orders table (currently it only joins to orders if you're only showing processed orders), eg change this:
strsql = strsql & " from oitems o " if GetConfig("xtopsellersprocessedonly") = "Yes" then if instr(ucase(xdatabasetype), "MYSQL") > 0 or instr(ucase(xdatabasetype), "SQLSERVER") > 0 then strsql = strsql & ", orders p WHERE o.orderid=p.orderid and p.oprocessed=1" else strsql = strsql & ", orders p WHERE o.orderid=p.orderid and p.oprocessed=TRUE" end if end if
to this:
strsql = strsql & " from oitems o,orders p where o.orderid=p.orderid " if GetConfig("xtopsellersprocessedonly") = "Yes" then if instr(ucase(xdatabasetype), "MYSQL") > 0 or instr(ucase(xdatabasetype), "SQLSERVER") > 0 then strsql = strsql & " and p.oprocessed=1" else strsql = strsql & " and p.oprocessed=TRUE" end if end if
then, immediately after that chunk of newly-changed code, in BOTH of those functions, you need to add the new clause for your days-ago restriction, and that'll be different syntax depending on the type of database you're using.
for sqlserver, add this: if (xbyz_cus_topsellers_max_days_ago<>"" and IsNull(xbyz_cus_topsellers_max_days_ago)=false) then strsql=strsql&" and odate >= DateAdd(Day, DateDiff(Day, 0, GetDate()) - "&xbyz_cus_topsellers_max_days_ago&", 0)" end if
for mysql, add this: if (xbyz_cus_topsellers_max_days_ago<>"" and IsNull(xbyz_cus_topsellers_max_days_ago)=false) then strsql=strsql&" and odate >= DATE_ADD( CURDATE(), INTERVAL -"&xbyz_cus_topsellers_max_days_ago&" DAY)" end if
for access, add this: if (xbyz_cus_topsellers_max_days_ago<>"" and IsNull(xbyz_cus_topsellers_max_days_ago)=false) then strsql=strsql&" and odate>=Date()-"&xbyz_cus_topsellers_max_days_ago end if
I haven't tried that yet, but in theory it should work.
I think I'll add that as a config option and argument on our byz093 (product-showcase) top sellers functions the next time I release a new version of it too as I'm sure it'd be useful for quite a lot of sites.
Simon Barnaby Developer [email protected] www.BigYellowZone.com www.BigYellowKey.com Follow us on Twitter: http://twitter.com/bigyellowzone Web Design, Online Marketing and VPASP addons |
Edited by - devshb on January 31 2013 20:34:07 |
|
|