View Single Post
  #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