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

Small mod: Leastsellers

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-28-2003, 08:51 PM
 
Alan Alan is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 83
 

Default Small mod: Leastsellers

Greetings,

I've basically "traced" the bestseller module to display products that aren't viewed much in your shop. If anyone have better optimization for search criterias for least viewed products, please do share!

Step: Paste stuff after #==Begin==# , and before #==End==# or just cut-and-paste the file.

Modify1: /x-cart-dir/modules/bestsellers.php
Code:
# $Id: bestsellers.php,v 1.4 2002/09/10 08:09:12 svowl Exp $ # # Bestsellers # # # Get products data for current category and store it into $products array # if ($cat) { $category_name = array_pop(func_query_first("SELECT category FROM $sql_tbl[categories] WHERE categoryid='$cat'")); $result = func_query("SELECT categoryid FROM $sql_tbl[categories] WHERE category LIKE '$category_name%'"); $str = "("; foreach($result as $k=>$v) { $str .= "$sql_tbl[products].categoryid='$v[categoryid]' OR $sql_tbl[products].categoryid1='$v[categoryid]' OR $sql_tbl[products].categoryid2='$v[categoryid]' OR $sql_tbl[products].categoryid3='$v[categoryid]' OR "; } $str = ereg_replace(" OR $", ")", $str); $search_query = "$str and $sql_tbl[products].forsale='Y' and $sql_tbl[products].avail>0 and $sql_tbl[products].views_stats>0 group by $sql_tbl[products].productid order by sales_stats DESC, views_stats DESC limit ".$config["Modules"]["number_of_bestsellers"]; #=======Begin===============# $search_query_reverse = "$str and $sql_tbl[products].forsale='Y' and $sql_tbl[products].avail>0 and $sql_tbl[products].views_stats>0 group by $sql_tbl[products].productid order by sales_stats ASC, views_stats ASC limit ".$config["Modules"]["number_of_bestsellers"]; #=======End================# } else #=======Begin--IMPORTANT=======# { #=======End--IMPORTANT========# $search_query = "$sql_tbl[products].forsale='Y' and $sql_tbl[products].avail>0 group by $sql_tbl[products].productid order by sales_stats DESC, views_stats DESC limit ".$config["Modules"]["number_of_bestsellers"]; #=======Begin===============# $search_query_reverse = "$sql_tbl[products].forsale='Y' and $sql_tbl[products].avail>0 group by $sql_tbl[products].productid order by sales_stats ASC, views_stats ASC limit ".$config["Modules"]["number_of_bestsellers"]; } #=======End================# # $bestsellers = func_query("SELECT $sql_tbl[products].* from $sql_tbl[products] WHERE $search_query"); $bestsellers = func_search_products($search_query, $user_account['membership']); #=======Begin===============# $bestsellers_reverse = func_search_products($search_query_reverse, $user_account['membership']); #=======End================# $smarty->assign("bestsellers",$bestsellers); #=======Begin===============# $smarty->assign("bestsellers_reverse",$bestsellers_reverse); #=======End================# ?>


I modified the left-column bestsellers menu to be the least sellers, but if you want the central section to be the leastsellers instead, use the same logic below for bestsellers.tpl. If you need help please let me know by PM.

Step: Create filemenu_bestsellers_reverse.tpl in /x-cart-dir/skin1/modules/Bestsellers/
Modify2: Cut and paste menu_bestsellers.tpl, add _reverse to all bestsellers wordings.
Code:
{* $Id: menu_bestsellers.tpl,v 1.5.2.1 2003/01/17 10:52:01 svowl Exp $ *} {* ==mod==Under Section, I've set max=5 to limit looping====*} {if $bestsellers_reverse} <TABLE border=0 cellPadding=5 cellSpacing=0 width=100%> <TR> <TD class=VertMenuTitleLeft height=26 width=5%></TD> <TD class=VertMenuTitle valign=center>{$lng.lbl_specials}</TD> </TR> <tr><td colspan=2 class=VertMenuItems> {section name=num loop=$bestsellers_reverse} {math equation="value+1" value=$smarty.section.num.index}. {/section} </td> </tr> </table> {/if}

Final Step: in /x-cart-dir/skin1/customer/home.tpl ammend
Code:
{include file="/modules/Bestsellers/menu_bestsellers.tpl"}
to
Code:
{include file="/modules/Bestsellers/menu_bestsellers_reverse.tpl"}
__________________
Best Regards!
Alan
Search is my friend
Reply With Quote
  #2  
Old 03-31-2003, 10:02 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

nice way of promoting unpopular products well done.
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 01-23-2004, 12:13 PM
  seaCOAST's Avatar 
seaCOAST seaCOAST is offline
 

X-Adept
  
Join Date: Oct 2002
Location: New Hampshire
Posts: 569
 

Default

I like this mod, but is there a way to get the Best Sellers list display the most "viewed" products instead of most sold?

BTW....running v3.5.3

__________________
Xcart V4.5.5 Gold
seaCOAST
"Live FREE or DIE!"
Reply With Quote
  #4  
Old 01-24-2004, 12:43 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

it is possible - you would need to amend the sql query in the bestsellers.php file that grabs the products depending on the sales stats and the view stats to just the view stats.
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 01-24-2004, 02:59 AM
  seaCOAST's Avatar 
seaCOAST seaCOAST is offline
 

X-Adept
  
Join Date: Oct 2002
Location: New Hampshire
Posts: 569
 

Default

Thanks funky...I think I got it to work.
__________________
Xcart V4.5.5 Gold
seaCOAST
"Live FREE or DIE!"
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 03:42 PM.

   

 
X-Cart forums © 2001-2020