您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop首页商品怎么实现随机排序
凌香2023-11-18 00:30:19ecshop商城教程已有人查阅
导读首页ecshop商品随机排序的三种方法都是修改inlcudes/lib_goods.php这个文件1 精品推荐 新品上架 热卖商品 促销商品 团购商品 拍卖商品 6类随机排序的调整方法
首页ecshop商品随机排序的三种方法都是修改inlcudes/lib_goods.php这个文件
1 精品推荐 新品上架 热卖商品 促销商品 团购商品 拍卖商品 6类随机排序的调整方法
将$order_type = 0;改为$order_type = 1
2修改“分类下的商品”排列顺序为随机
将assign_cat_goods这个函数中的sql
3 修改“品牌的商品”排列顺序为随机
在assign_brand_goods这个函数的前面加入一句“$order_type = 1;”,将该函数下方第五行的“$sql .= ' ORDER BY g.sort_order, g.goods_id DESC';”改为“$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.goods_id DESC' : ' ORDER BY RAND()';”即可
就是将
1 精品推荐 新品上架 热卖商品 促销商品 团购商品 拍卖商品 6类随机排序的调整方法
将$order_type = 0;改为$order_type = 1
2修改“分类下的商品”排列顺序为随机
将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()';
其实就是在 行加上一句“$order_type = 1;”,在最后一行的前面加上“$sql .= $order_type == 0 ? ”,后面加上“ : ' ORDER BY RAND()'”,别忘了是在最后的“;”之前3 修改“品牌的商品”排列顺序为随机
在assign_brand_goods这个函数的前面加入一句“$order_type = 1;”,将该函数下方第五行的“$sql .= ' ORDER BY g.sort_order, g.goods_id DESC';”改为“$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.goods_id DESC' : ' ORDER BY RAND()';”即可
就是将
function assign_brand_goods($brand_id, $num = 0, $cat_id = 0)
{
$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, 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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '$brand_id'";
if ($cat_id > 0)
{
$sql .= get_children($cat_id);
}
$sql .= ' ORDER BY g.sort_order, g.goods_id DESC';
改为
function assign_brand_goods($brand_id, $num = 0, $cat_id = 0)
{
$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, 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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '$brand_id'";
if ($cat_id > 0)
{
$sql .= get_children($cat_id);
}
$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.goods_id DESC' : ' ORDER BY RAND()';
本文标签:
很赞哦! ()
相关文章
随机图文
-
ecshop后台添加新功能栏目权限管理管理员列表权限控制
ECSHOP后台添加新功能栏目权限管理管理员列表权限控制一、添加菜单项 打开 /admin/includes/inc_menu.php文件( -
ecshop文章列表页调用文章描述信息的方法
注意:这里所说的描述信息,指的是在ECSHOP后台发布文章时,填写的那个“网页描述”信息。 -
ecshop后台订单列表增加快递单号搜索订单的功能
利用ECSHOP运营商城时,如果订单比较多,想要通过快递单号查看一个订单时,一条一条的查看非常麻烦,如果能够通过快递单号直接搜索到订单就好了。 -
ipad等智能机访问ecshop网站不跳转wap的修复方法
打开ecshop文件,找到修改index.php找到 $ua = strtolower($_SERVER['HTTP_USER_AGENT']); 做如下代码修改(增加了普通手机的ua代码
留言与评论 (共有 条评论) |