怎样让ecshop分类下的商品随机显示
1个回答
展开全部
添加order by
将根目录下的inlcudes/lib_goods.php文件打开,将assign_cat_goods这个函数中的sql
$sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
'g.promote_price, promote_start_date, 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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND '.
'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ' .
'ORDER BY g.sort_order, g.goods_id DESC';
改为
$order_type = 1;
$sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
'g.promote_price, promote_start_date, 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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND '.
'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ' ;
$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.goods_id DESC' : ' ORDER BY RAND()';
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询