广告投放

ECSHOP商品详情页相关属性商品,由新到旧排序的修改教程

目录

    ecshop商品详情页相关属性商品由新到旧排序修改教程

    ECSHOP 商品详情页相关属性商品由新到旧排序

    打开文件 includes/lib_goods.php

    查找以下代码

                /* 查找符合条件的商品 */
                $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
                            "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
                            'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
                        'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
                        'LEFT JOIN ' . $GLOBALS['ecs']->table('goods_attr') . ' as a ON g.goods_id = a.goods_id ' .
                        "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
                            "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
                        "WHERE a.attr_id = '$key' AND g.is_on_sale=1 AND a.attr_value = '$val[value]' AND g.goods_id <> '$_REQUEST[id]' " .
                        'LIMIT ' . $GLOBALS['_CFG']['attr_related_number'];
                $res = $GLOBALS['db']->getAll($sql);

    修改成

                /* 查找符合条件的商品 */
                $sql = 'SELECT DISTINCT  g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
                            "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
                            'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
                        'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
                        'LEFT JOIN ' . $GLOBALS['ecs']->table('goods_attr') . ' as a ON g.goods_id = a.goods_id ' .
                        "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
                            "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
                        "WHERE a.attr_id = '$key' AND g.is_on_sale=1 AND a.attr_value = '$val[value]' AND g.goods_id <> '$_REQUEST[id]' " .
                        ' ORDER BY  g.goods_id  DESC ' . ' LIMIT ' . $GLOBALS['_CFG']['attr_related_number'];
                $res = $GLOBALS['db']->getAll($sql);

    这样就可以了。

    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

    给TA打赏
    共{{data.count}}人
    人已打赏
    广告位招租919838898
    0 条回复 A文章作者 M管理员
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    有新私信 私信列表
    搜索