STEP1: Add a field to the table "ecs_goods": salesnum (note: custom field name)
STEP2: Open the file in the root directory: flow.php
Find the following code:
/* Insert order goods*/
$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-& gt;table(' cart') .
WHERE session_id = '".SESS_ID."' AND rec_type = '$flow_type'"; Below this code, add the following code:
/* Insert the salesnum field of the product table to count the 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: defaultlibrarygoods_list.lbi, find the following code:
ASCDESC#goods_list”>
Add below the above code:
ASCDESC#goods_list ”>{$pager.order}default.gif” alt=”Ranked by sales volume”>
The difference between the two pieces of code, you can analyze it yourself.
STEP4: Open the file: category.php and find the following code:
$sort = (isset($_REQUEST['sort']) && in_array(trim( strtolower($_REQUEST['sort'])), array('goods_id', 'shop_price', 'last_update')))
Modified to:
$ sort = (isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('goods_id', 'shop_price', 'last_update','salesnum')))