您现在的位置是:首页 > 教程 > 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编辑器Fckeditor上传图片中文名称乱码的解决方法
中文名乱码是因为:FCKeditor使用UTF-8编码,自己机子比如是Windows系统文件名使用的是GBK编码,在上传中需要,改下编码,从UTF-8到GBK -
ecshop购买记录增加显示更多购买信息的方法
ecshop的购买记录无论程序还是ECSHOP模板都默认只显示用户名、购买时间、购买数量以及成交与否这几项信息。实际使用过程发现,其实只显示这四项信息不够友好 -
ecshop验证码图片无法显示解决办法
客户在安装好ecshop之后所有前台的证码不显示,后台可以显示,ECSHOP开发中心总结了解决办法分享给各位朋友。 -
ecshop商城将首页的轮换图由flash更换为js播放器的方法
在进行ecshop二次开发时有时需要将ecshop首页的轮换图的样式进行更换,那应该如何去做呢,其实这个也是很简单的:
留言与评论 (共有 条评论) |