让ecshop首页的销售排行显示指定价格区间的商品
很多ecshop网店的商品价格多样,往往便宜的小商品或者补拍邮费之类的销售量最大,但这些非主体商品显示在排行榜中很不好看,对广告宣传效果也不好。如果指定某个价格以上的商品才显示在排行榜中,则好看多了。修改方法如下:
1、打开\includes\lib_goods.php,把function get_top10($cats = '')函数另复制一个并稍修改一下(原代码不要改,不然分类页全都变了),改成如下样子:
很多网店的商品价格多样,往往便宜的小商品或者补拍邮费之类的销售量最大,但这些非主体商品显示在排行榜中很不好看,对广告宣传效果也不好。如果指定某个价格以上的商品才显示在排行榜中,则好看多了。修改方法如下:
1、打开\includes\lib_goods.php,把function get_top10($cats = '')函数另复制一个并稍修改一下(原代码不要改,不然分类页全都变了),改成如下样子:
* 首页调用销售排行榜
*
* @access public
* @param string $cats 查询的分类
* @return array
*/
function get_index_top10($cats = '')
{
$cats = get_children($cats);
$where = !empty($cats) ? "AND ($cats OR " . get_extension_goods($cats) . ") " : '';
$sql = 'SELECT g.goods_id, g.goods_name, g.shop_price, g.goods_thumb, SUM(og.goods_number) as goods_number ' .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g, ' .
$GLOBALS['ecs']->table('order_info') . ' AS o, ' .
$GLOBALS['ecs']->table('order_goods') . ' AS og ' .
"WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.shop_price >= 10 AND g.is_delete = 0 $where $top10_time " ;
//判断是否启用库存,库存数量是否大于0
if ($GLOBALS['_CFG']['use_storage'] == 1)
{
$sql .= " AND g.goods_number > 0 ";
}
$sql .= ' AND og.order_id = o.order_id AND og.goods_id = g.goods_id ' .
"AND (o.order_status = '" . OS_CONFIRMED . "' OR o.order_status = '" . OS_SPLITED . "') " .
"AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') " .
"AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') " .
'GROUP BY g.goods_id ORDER BY goods_number DESC, g.goods_id DESC LIMIT ' . $GLOBALS['_CFG']['top_number'];
$arr = $GLOBALS['db']->getAll($sql);
for ($i = 0, $count = count($arr); $i < $count; $i++)
{
$arr[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($arr[$i]['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $arr[$i]['goods_name'];
$arr[$i]['url'] = build_uri('goods', array('gid' => $arr[$i]['goods_id']), $arr[$i]['goods_name']);
$arr[$i]['thumb'] = get_image_path($arr[$i]['goods_id'], $arr[$i]['goods_thumb'],true);
$arr[$i]['price'] = price_format($arr[$i]['shop_price']);
$arr[$i]['buy_num'] = get_buy_sum($arr[$i]['goods_id']);
}
return $arr;
}
2、打开\index.php,找到
$smarty->assign('top_goods', get_top10());
修改为
$smarty->assign('top_goods', get_index_top10());
后台清除缓存,首页排行榜显示的就是价格在10元以上的商品了。
下一篇: 让ecshop文章列表以更新时间排序 上一篇: 权限细分:让客服查看会员列表但不能编辑会员资料