欢迎您来到素材猫
充值

ECSHOP商品随机自动关联相关商品插件安装方法

  • 时间:2020-05-19 12:15 编辑:素材猫 来源:素材猫 阅读:113
  • 扫一扫,手机访问
摘要:ECSHOP商品随机自动关联相关商品插件安装方法

安装步骤: (下面是以默认官方程序为例,具体根据您的程序文件修改)

一、进入 【后台 》数据库管理 SQL查询】,输入下面SQL语句执行

注意:数据库ecs_前缀,要根据你的数据库进行修改

INSERT INTO   `ecs_shop_config` ( `id`, `parent_id`, `code`, `type`, `store_range`,   `store_dir`, `value`, `sort_order` ) VALUES    ('', '7', 'show_random_related_goods', 'select', '1,0', '', '1', '1');

 

 

二、打开/includes/lib_goods.php文件

最下面 ?> 的上一行加入以下代码:

function   get_random_related_goods($cat_id)

{

    $children = get_children($cat_id);

    $cat = $GLOBALS['db']->getRow('SELECT   cat_name, keywords, cat_desc, grade, filter_attr, parent_id FROM ' .   $GLOBALS['ecs']->table('category') . " WHERE cat_id =   '$cat_id'");

 

    $where = "g.is_on_sale = 1 AND   g.is_alone_sale = 1 AND g.is_delete = 0 AND ($children OR " .   get_extension_goods($children) . ')';

    $count =   $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' .   $GLOBALS['ecs']->table('goods') . " AS g WHERE $where ");

    $size = isset($_CFG['related_goods_number'])   && intval($_CFG['related_goods_number']) > 0 ?   intval($_CFG['related_goods_number']) : 4;

    $max_page = ($count> 0) ? ceil($count   / $size) : 1;

    $page = rand(1, $max_page);

 

    $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')   . ' 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.cat_id = '$cat_id'   AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ";

    $res =   $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);

 

    $arr = array();

    while ($row =   $GLOBALS['db']->fetchRow($res))

    {

        $arr[$row['goods_id']]['goods_id']     = $row['goods_id'];

          $arr[$row['goods_id']]['goods_name']     = $row['goods_name'];

          $arr[$row['goods_id']]['short_name']     = $GLOBALS['_CFG']['goods_name_length'] > 0 ?

            sub_str($row['goods_name'],   $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];

          $arr[$row['goods_id']]['goods_thumb']    = get_image_path($row['goods_id'], $row['goods_thumb'], true);

          $arr[$row['goods_id']]['goods_img']      = get_image_path($row['goods_id'], $row['goods_img']);

        $arr[$row['goods_id']]['market_price']   = price_format($row['market_price']);

          $arr[$row['goods_id']]['shop_price']     = price_format($row['shop_price']);

        $arr[$row['goods_id']]['url']          = build_uri('goods',   array('gid'=>$row['goods_id']), $row['goods_name']);

 

        if ($row['promote_price'] > 0)

        {

              $arr[$row['goods_id']]['promote_price'] =   bargain_price($row['promote_price'], $row['promote_start_date'],   $row['promote_end_date']);

            $arr[$row['goods_id']]['formated_promote_price']   = price_format($arr[$row['goods_id']]['promote_price']);

        }

        else

        {

              $arr[$row['goods_id']]['promote_price'] = 0;

        }

    }

 

    return $arr;

}

 

 

三、打开/languages/zh_cn/admin/shop_config.php文件

找到如下代码:

$_LANG['cfg_name']['show_marketprice']   = '是否显示市场价格';

在以上这段代码的下面加:

$_LANG['cfg_name']['show_random_related_goods']   = '是否开启随机关联相关商品';

 

找到如下代码:

$_LANG['cfg_range']['show_marketprice']['0']   = '不显示';

在以上这段代码的下面加:

$_LANG['cfg_range']['show_random_related_goods']['1']   = '开启';

$_LANG['cfg_range']['show_random_related_goods']['0']   = '关闭';

 

 

四、打开/goods.php文件

找到如下代码:

$linked_goods =   get_linked_goods($goods_id);

将以上这段代码修改成如下代码:

        if   ($_CFG['show_random_related_goods'] == 1)

        {

            $linked_goods =   get_random_related_goods($goods['cat_id']);

        }

        else

        {

            $linked_goods =   get_linked_goods($goods_id);

        }

 

 

 

恭喜你通过以上操作便可实现商品随机自动关联相关商品功能

ECSHOP商品随机自动关联相关商品插件下载地址:https://www.sucaimao.com/product/view316697.html

  • 全部评论(0)
最新发布的资讯信息
【计算机/互联网|】Proxmox Linux 测试架设流程(2020-06-06 18:01)
【技术支持|】720云VR全景系统网站源码安装说明(2020-06-06 17:48)
【计算机/互联网|】Python 直接嵌入到 Linux 内核还感觉有些惊讶(2020-06-06 17:30)
【技术支持|】CRMEB商城搭建说明(2020-06-06 16:14)
【技术支持|】免xp框架监听短信使用教程(2020-06-05 10:51)
【计算机/互联网|】eps免费版详细装说明(2020-05-27 12:04)
【计算机/互联网|】在 Tomcat 里面部署 Web 项目的几种方式(2020-05-24 11:14)
【技术支持|】PHP设计模式-仓库模式Repository(2020-05-24 11:08)
【计算机/互联网|】MAC 使用XAMPP 建立PHP 开发环境教学(2020-05-24 11:03)
【好东西分享|】方便你备份重要资料的免费工具:AnyBackup 1.8(2020-05-23 12:05)
联系我们
工作时间:8:00-23:30
客服 QQ:116622333
邮 箱:sucaimao#qq.com