实现ecshop分类下随机显示商品,打破后台规定的按照上架时间,价格、等先后顺序排序,让很多人上传
完毕产品,第一页总是显示同类商品,如何修改ecshop随机显示产品分类页面下的产品,最模板告诉你方法:
1、下载ecshop并备份你的根目录下的文件category.php文件
2、找到如下代码部分,大约在450行:
-
/* 获得商品列表 */
-
$sql = ‘SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ‘ .
-
“IFNULL(mp.user_price, g.shop_price * ‘$_SESSION[discount]‘) AS shop_price, g.promote_price, g.goods_type, ” .
-
‘g.promote_start_date, g.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 $where $ext ORDER BY $sort $order”;
替换修改为
-
$zz=1;
-
$sql = ‘SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ‘ .
-
“IFNULL(mp.user_price, g.shop_price * ‘$_SESSION[discount]‘) AS shop_price, g.promote_price, g.goods_type, ” .
-
‘g.promote_start_date, g.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 $where $ext”;
-
$sql .= $zz == 0 ? ” $order” : ” ORDER BY RAND()”;
即可实现ecshop分类下的产品随机显示了,但是前提是,到后台清空缓存来实现,不能每次刷新都随机,否
则服务器会受不了的,这样就实现了和首页精品、新品、促销等栏目同样的功能。
通过ecshop清空缓存来实现产品的随机,随机显示竟然会占用服务器过多资源。所以不建议这样优化!
(责任编辑:最模板) |