table('order_goods')."wheregoods_id='$go..."/>

ECshop商品列表页及详细页显示商品的出售量

1.打开includes/lib_goods.php,在文件中添加以下方法:


/**
  * 查询商品的出售数量
  * @param   int     $goods_id   商品id
  * @return  int
  */ 
  function sales_volume($goods_id)  {
	  $sql= "select sum(goods_number) as count from ".$GLOBALS['ecs']->table('order_goods')." where goods_id = '$goods_id'";
	  $res = $GLOBALS['db']->getOne($sql);
	  if($res>0){ return $res; }else{ return('0'); }
  }



 
2.打开category.php文件,在大概516行(while循环中)插入:$arr[$row['goods_id']]['sales_volume'] = sales_volume($row['goods_id']);  调用代码为:{$goods.sales_volume}
 
3.打开goods.php文件,在大概190行处插入代码:$goods['sales_volume'] = sales_volume($goods_id);  调用代码为:{$goods.sales_volume}
 
效果如下图所示
\
(by:LiuR_Fun-刘锐芬)


欢迎转载,原文地址:http://www.lrfun.com/html/technology/ECSHOP/2015/0409/41.html

上一篇:ECshop商品增加[按点击率排行]
下一篇:没有了