STEP1: Add field in Table "Ecs_goods": salesnum (Note: custom field name)
STEP2: Open the root directory file: flow.php
Locate the following code:
/ * Insert Order item * /
$sql = "INSERT into". $ecs->table (' Order_goods '). "(".
"order_id, goods_id, Goods_name, GOODS_SN, product_id , Goods_number, Market_price,".
"Goods_price, Goods_attr, Is_real, Extension_code, parent_id, Is_gift, goods_attr_id) ".
"SELECT ' $new _order_id ', goods_id, Goods_name, GOODS_SN, product_id, Goods_number, Market_price,".
"Goods_price, Goods_attr, Is_real, Extension_code, parent_id, Is_gift, goods_attr_id".
"from". $ecs->table (' cart ').
"WHERE session_id = '". sess_id. "' and Rec_type = ' $flow _type ' ";
$db->query ($sql);
below this code, add the following code:
/ * Insert the Salesnum field of the Product table, statistics sales ranking * /
$sql = "Update". $GLOBALS [' ECS ']->table (' goods '). " As a, ". $GLOBALS [' ECS ']->table (' cart ')." As B ".
"Set a.salesnum= A.salesnum + B.goods_number".
"WHERE a.goods_id=b.goods_id and b.session_id = '". sess_id. "' and B.rec_type = ' $flow _type ' ";
$db->query ($sql);
STEP3: Open file: Default\library\goods_list.lbi, locate the following code:
<a href= "category.php?category={$category}&display={$pager. display}&brand={$brand _id}&price_ min={$price _min}&price_max={$price _max}&filter_attr={$filter _attr}&page={$pager. page}&sort= Last_update&order=<!–{if $pager. Sort = = ' last_update ' && $pager. Order = = ' DESC '}–>asc<!–{else}–& Gt;desc<!–{/if}–> #goods_list ">{$pager. Order}<!–{else}–>default<!–{/if}–>.gif "alt=" {$lang. sort.last_update} "></a>
in the above code, add the following:
<a href= "category.php?category={$category}&display={$pager. display}&brand={$brand _id}&price_ min={$price _min}&price_max={$price _max}&filter_attr={$filter _attr}&page={$pager. page}&sort= Salesnum&order=<!–{if $pager. Sort = = ' Salesnum ' && $pager. Order = = ' DESC '}–>asc<!–{else}–>des C<!–{/if}–> #goods_list ">{$pager. Order }<!–{else}–>default<!–{/if}–>.gif "alt=" by sales ></a>
the difference between the two sections of the code, to analyze their own to see it.
STEP4: Open file: category.php, find the following code:
$sort = (isset ($_request[' sort ')) && In_array (Trim (strtolower ($_request[' sort ')), array (' goods_id ', ' sh Op_price ', ' last_update ' )))
modified to:
$sort = (isset ($_request[' sort ')) && In_array (Trim (strtolower ($_request[' sort ')), array (' goods_id ', ' sh Op_price ', ' last_update ', ' Salesnum ' ))
Ecshop Product List page increase by sales order