ECSHOP首页显示商品销量

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);
}
在大概317行的位置
$goods[$idx]['brand_name']   = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
下,添加
$goods[$idx]['buy_num']		 = get_buy_sum($row['goods_id']);

2.themes\default\index.dwt 中,相关位置添加

累计销量:{$goods.buy_num}0

你可能感兴趣的:(ecshop)