首页推荐的新品怎样按时间排序

2016-07-07 15:21 来源:www.chinab4c.com 作者:ecshop专家

就是首页我设置了显示8件新品,排序按最后更新的显示在最前面。现在我的系统的首页不知道是这么回事,显示的乱七八糟的,不是按最新上的排序,而是显示很早前的商品和最近的商品

回答:
你的模版是默认模版么?



模板是下载的模板,在更多商品seach里显示正常,就首页的问题,这情况哪个文件的代码有关系呢?我试了用系统默认的模板情况一样的,首页新品不是按最新上的显示

这论坛真冷啊,几乎问题没人回答

这个和模板没任何关系。你看lib_goods.php里面的代码。是按商品排序编码 和 最后更新时间来处理的
ORDER BY g.sort_order, g.last_update DESC

谢谢楼上,等了几天终于有人回答,我去试下

好像看代码没问题
//初始化数据
$type_goods['best'] = array();
$type_goods['new'] = array();
$type_goods['hot'] = array();
$data = read_static_cache('recommend_goods');
if ($data === false)
{
$sql = 'SELECT g.goods_id, g.is_best, g.is_new, g.is_hot, g.is_promote, b.brand_name,g.sort_order ' .
' FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
' LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' .
' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.is_best = 1 OR g.is_new =1 OR g.is_hot = 1)'.
' ORDER BY g.sort_order, g.last_update DESC';
$goods_res = $GLOBALS['db']->getAll($sql);
//定义推荐,最新,热门,促销商品
$goods_data['best'] = array();
$goods_data['new'] = array();
$goods_data['hot'] = array();
$goods_data['brand'] = array();
if (!empty($goods_res))
{
foreach($goods_res as $data)
{
if ($data['is_best'] == 1)
{
$goods_data['best'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['is_new'] == 1)
{
$goods_data['new'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['is_hot'] == 1)
{
$goods_data['hot'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['brand_name'] != '')
{
$goods_data['brand'][$data['goods_id']] = $data['brand_name'];
}
}
}
write_static_cache('recommend_goods', $goods_data);
}
else
{
$goods_data = $data;
}

$time = gmtime();
$order_type = $GLOBALS['_CFG']['recommend_order'];

有高手吗