VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 General help me questions
 Restrict ''Top Sellers'' to last year or so
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

InkMagic
VP-ASP New User

107 Posts

Posted - January 24 2013 :  23:03:11  Show Profile  Reply with Quote
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

InkMagic
VP-ASP New User

107 Posts

Posted - January 31 2013 :  15:26:54  Show Profile  Reply with Quote
Gee, my question has been read hundreds of times but no suggestions?

Doesn't anyone have an older site with older items that were top sellers in their day but should not be on today's top selling list?

No suggestions how to limit the top sellers to those for only the past 6 months?

No one from VPASP with an anser?

Thank you

Dale
Go to Top of Page

devshb
Senior Member

United Kingdom
1898 Posts

Posted - January 31 2013 :  20:03:01  Show Profile  Visit devshb's Homepage  Reply with Quote
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
Go to Top of Page

InkMagic
VP-ASP New User

107 Posts

Posted - February 01 2013 :  15:26:26  Show Profile  Reply with Quote
Hi Simon:

Hey, I did exactly what you said .... took about 5 minutes ... AND it worked perfectly. Now all my 'Top Selling' products are current AND they are actually my best selling products for the past 6 months!!

I can't thank you enough.

I'll have a look at your 'product-showcase' add-on too.

Thanks again ... Dale
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000