×
  官方微博: 腾讯   新浪
ECSHOP模板 
食品保健 家居化妆 家电数码 综合通用 珠宝配饰
VIP免费模板 
家居化妆 综合通用 服装饰品 食品保健 家电数码
ECSHOP插件 
ECSHOP插件 SHOPEX插件
EC教程中心
安装使用网店运营
首页 > 二次开发教程 > ECSHOP商品列表页显示每个商品的评论等级、评论数量、点击量、销售量!

帮助目录

有问必答

您可以加入我们的官方QQ群。

加入官方QQ群

可以将问题或建议反馈给我们。

提交在线客服

猜您感兴趣

ECSHOP商品列表页显示每个商品的评论等级、评论数量、点击量、销售量!

网站开发中心/ 2015-01-16/ 关注人气:1265

怎么才能让ECSHOP商品列表页显示每个商品的评论等级、评论数量、点击量、销售量呢,现在ECSHOP网站开发中心官方技术来告诉你该怎么做吧!下面是修改方法:

 

第一步:
首先修改category.php 文件,定位到 category_get_goods() 函数部分
找到
 
$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";
 
将之修改为
 
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price,g.click_count, 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, " .
" IFNULL(AVG(r.comment_rank),0) AS comment_rank,IF(r.comment_rank,count(*),0) AS comment_count, ".
'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]' " .
' LEFT JOIN '. $GLOBALS['ecs']->table('comment') .' AS r '.
'ON r.id_value = g.goods_id AND comment_type = 0 AND r.parent_id = 0 AND r.status = 1 ' .
"WHERE $where $ext group by g.goods_id ORDER BY $sort $order";
 
然后继续找到
 
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
 
在它下面增加几行代码
 
$row['comment_rank'] = ceil($row['comment_rank']) == 0 ? 5 : ceil($row['comment_rank']);
$arr[$row['goods_id']]['comment_rank']=$row['comment_rank'];
$arr[$row['goods_id']]['comment_count']=$row['comment_count'];
 
$arr[$row['goods_id']]['buy_num'] = get_buy_sum($row['goods_id']);
$arr[$row['goods_id']]['click_count'] = $row['click_count'];
 
第二步
 
第1步:打开文件 includes/lib_goods.php
在该文件的末尾添加如下代码片段
 
function get_buy_sum($goods_id)
{
$sql = "select sum(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id ;
return $GLOBALS['db']->getOne($sql);
}
 
第三步(以官方默认模板为例):
 
修改 themes/default/library/goods_list.lbi 文件
找到对应的位置修改
 
<img src="images/stars{$goods.comment_rank}.gif" style="width:78px;height:15px;" /><br> 
评论数:{$goods.comment_count}<br>
点击量:{$goods.click_count}<br>
销售量:{if $goods.buy_num}{$goods.buy_num}{else}0{/if}
 
是不是很简单呢,模板样式自己设定哦...
分享到:
下一篇:ecshop 商品列表页面增加按销售 销量排行
上一篇:ecshop会员退出登录后仍然保留购物车里的商品