您现在的位置是:首页 > 教程 > 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商品页发表评论时取消E-MAIL必填的方法
ECSHOP的商品详情页,在用户提交评论的时候,那个“E-MAIL”输入框默认是“必填”的。如果我想改成“E-MAIL非必填”或者干脆 -
ecshop在线调查,ecshop会员访问在线调查
ECSHOP在线调查。进入网店后台,点击左侧导航栏中的文章管理 -> 在线调查。一 调查主题:填写调查主题。二 调查选项 -
ecshop注册用户送红包系统实现自动给新会员送红包
功能介绍:新用户成功注册之后,系统自动赠送红包,用户在会员中心就可以查看到红包,而管理员不用手动的在后台按会员发放。 -
ecshop的qq客服无法发起临时会话解决方法
ECHSOP qq客服无法发起临时会话解决方法:抱歉,无法发起临时会话,您可以添加对方为好友以发送消息把QQ客服在线聊天代码改成:
留言与评论 (共有 条评论) |