Ecshop Product List page increase by sales order

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.