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)
-   -   Small mod: Leastsellers (https://forum.x-cart.com/showthread.php?t=2074)

Alan 03-28-2003 08:51 PM

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"}

funkydunk 03-31-2003 10:02 AM

nice way of promoting unpopular products :D well done.

seaCOAST 01-23-2004 12:13 PM

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

:-)

funkydunk 01-24-2004 12:43 AM

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.

seaCOAST 01-24-2004 02:59 AM

Thanks funky...I think I got it to work. :D


All times are GMT -8. The time now is 03:38 PM.

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