欢迎访问 夜阑小雨 我的学习碎片档案,这里记录了我的学习内容和工作中经验,希望给您带去帮助。

ecshop 产品列表页添加按收藏排序

Ecshop 夜阑小雨 1663℃ 0评论

ecshop 中没有按收藏排序,但是有一个表记录了 收藏数量。所以只需要改几个地方就可以实现了。

 

1. 修改goods_stor.lbi

在排序下面添加

 <li> <a href=”{$script_name}.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=collect&order=<!– {if $pager.sort == ‘collect && $pager.order == ‘DESC’} –>ASC<!– {else} –>DESC<!– {/if} –>#goods_list”><img src=”images/collect_<!– {if $pager.sort == ‘collect‘} –>{$pager.order}<!– {else} –>default<!– {/if} –>.gif” alt=”收藏”></a> </li>
   </ul>

 

2.修改 category。php文件

修改 $sort变量增加collect:

$sort  = (isset($_REQUEST[‘sort’])  && in_array(trim(strtolower($_REQUEST[‘sort’])), array(‘goods_id’, ‘shop_price’, ‘last_update’,’click_count’,’is_hot’,collect))) ? trim($_REQUEST[‘sort’])  : $default_sort_order_type;

 

修改 function category_get_goods中 $sql 语句为:

  /* 获得商品列表 */
   if($sort == ‘collect’){
    $sql = ‘select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price, g.goods_thumb , g.goods_img , IFNULL(ncg.num,0) from ‘. $GLOBALS[‘ecs’]->table(‘goods’) .’ as g left join (select COUNT(cg.goods_id) as num, cg.goods_id FROM ‘ . $GLOBALS[‘ecs’]->table(‘collect_goods’) . ‘ as cg group by cg.goods_id) as ncg on g.goods_id = ncg.goods_id WHERE ‘.$where.’ order by ncg.num ‘.$order;
  
 }else{
  $sql = ‘SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ‘ .
     “IFNULL(mp.user_price, g.shop_price * ‘$_SESSION[discount]’) AS shop_price, g.promote_price, g.goods_type, ” .
     ‘g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ‘ .
    ‘FROM ‘ . $GLOBALS[‘ecs’]->table(‘goods’) . ‘ AS g ‘ .
    ‘LEFT JOIN ‘ . $GLOBALS[‘ecs’]->table(‘member_price’) . ‘ AS mp ‘ .
     “ON mp.goods_id = g.goods_id AND mp.user_rank = ‘$_SESSION[user_rank]’ ” .
    “WHERE $where $ext ORDER BY $sort $order”; 
 }

 

转载请注明:夜阑小雨 » ecshop 产品列表页添加按收藏排序

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址