客服热线:189-2701-5231
登录注册

ecshop颜色属性用图片代替安装教程

发布日期:2017-10-21

ecshop颜色属性用图片代替安装教程,ECShop实现商品颜色属性用颜色图片显示

对本插件有兴趣的可以联系在线客服QQ292480793



1. “直接替换的程序”里面的文件传到你网站的根目录下

2.打开admin/templates/goods_list.htm

   找到代码

{if $specifications[$goods.goods_type] neq ''}

{if $specifications[$goods.goods_type] neq ''}<a href="goods.php?act=product_list&goods_id={$goods.goods_id}" title="{$lang.item_list}"><img src="images/icon_docs.gif" width="16" height="16" border="0" /></a>{/if}

在后面加上

{if $specifications[$goods.goods_type] neq ''}

<a href="product_spec_pic.php?act=list&goods_id={$goods.goods_id}" title="{$lang.specification_pic}"><img src="images/guigou_icon.png" width="16" height="16" border="0" /></a>{else}<img src="images/empty.gif" width="16" height="16" border="0" /> {/if}

 

3.打开根目录下includes/lib_goods.php文件找到

  /**

 * 获得商品的属性和规格

 *

 * @access  public

 * @param   integer $goods_id

 * @return  array

 */

function get_goods_properties($goods_id)

{

    /* 对属性进行重新排序和分组 */

    $sql = "SELECT attr_group ".

            "FROM " . $GLOBALS['ecs']->table('goods_type') . " AS gt, " . $GLOBALS['ecs']->table('goods') . " AS g ".

            "WHERE g.goods_id='$goods_id' AND gt.cat_id=g.goods_type";

    $grp = $GLOBALS['db']->getOne($sql);

 

    if (!empty($grp))

    {

        $groups = explode("\n", strtr($grp, "\r", ''));

    }

 

    /* 获得商品的规格 */

    $sql = "SELECT a.attr_id, a.attr_name, a.attr_group, a.is_linked, a.attr_type, ".

                "g.goods_attr_id, g.attr_value, g.attr_price " .

            'FROM ' . $GLOBALS['ecs']->table('goods_attr') . ' AS g ' .

            'LEFT JOIN ' . $GLOBALS['ecs']->table('attribute') . ' AS a ON a.attr_id = g.attr_id ' .

            "WHERE g.goods_id = '$goods_id' " .

            'ORDER BY a.sort_order, g.attr_price, g.goods_attr_id';

    $res = $GLOBALS['db']->getAll($sql);

 

    $arr['pro'] = array();     // 属性

    $arr['spe'] = array();     // 规格

    $arr['lnk'] = array();     // 关联的属性

 

    foreach ($res AS $row)

    {

        $row['attr_value'] = str_replace("\n", '<br />', $row['attr_value']);

 

        if ($row['attr_type'] == 0)

        {

            $group = (isset($groups[$row['attr_group']])) ? $groups[$row['attr_group']] : $GLOBALS['_LANG']['goods_attr'];

 

            $arr['pro'][$group][$row['attr_id']]['name']  = $row['attr_name'];

            $arr['pro'][$group][$row['attr_id']]['value'] = $row['attr_value'];

        }

        else

        {

            $arr['spe'][$row['attr_id']]['attr_type'] = $row['attr_type'];

            $arr['spe'][$row['attr_id']]['name']     = $row['attr_name'];

            $arr['spe'][$row['attr_id']]['values'][] = array(

                                                        'label'        => $row['attr_value'],

                                                        'price'        => $row['attr_price'],

                                                        'format_price' => price_format(abs($row['attr_price']), false),

                                                        'id'           => $row['goods_attr_id']);

        }

 

        if ($row['is_linked'] == 1)

        {

            /* 如果该属性需要关联,先保存下来 */

            $arr['lnk'][$row['attr_id']]['name']  = $row['attr_name'];

            $arr['lnk'][$row['attr_id']]['value'] = $row['attr_value'];

        }

    }

 

    return $arr;

}

 

改成

 

/**

 * 获得商品的属性和规格

 *

 * @access  public

 * @param   integer $goods_id

 * @return  array

 */

function get_goods_properties($goods_id)

{

    /* 对属性进行重新排序和分组 */

    $sql = "SELECT attr_group ".

            "FROM " . $GLOBALS['ecs']->table('goods_type') . " AS gt, " . $GLOBALS['ecs']->table('goods') . " AS g ".

            "WHERE g.goods_id='$goods_id' AND gt.cat_id=g.goods_type";

    $grp = $GLOBALS['db']->getOne($sql);

 

    if (!empty($grp))

    {

        $groups = explode("\n", strtr($grp, "\r", ''));

    }

 

    /* 获得商品的规格 */

    $sql = "SELECT a.attr_id, a.attr_name, a.attr_group, a.is_linked, a.attr_type, ".

                "g.goods_attr_id, g.attr_value, g.attr_price,g.thumb_url,g.img_url,g.img_original, hex_color " .

            'FROM ' . $GLOBALS['ecs']->table('goods_attr') . ' AS g ' .

            'LEFT JOIN ' . $GLOBALS['ecs']->table('attribute') . ' AS a ON a.attr_id = g.attr_id ' .

            "WHERE g.goods_id = '$goods_id' " .

            'ORDER BY a.sort_order, g.attr_price, g.goods_attr_id';

    $res = $GLOBALS['db']->getAll($sql);

 

    $arr['pro'] = array();     // 属性

    $arr['spe'] = array();     // 规格

    $arr['lnk'] = array();     // 关联的属性

 

    foreach ($res AS $row)

    {

        $row['attr_value'] = str_replace("\n", '<br />', $row['attr_value']);

 

        if ($row['attr_type'] == 0)

        {

            $group = (isset($groups[$row['attr_group']])) ? $groups[$row['attr_group']] : $GLOBALS['_LANG']['goods_attr'];

 

            $arr['pro'][$group][$row['attr_id']]['name']  = $row['attr_name'];

            $arr['pro'][$group][$row['attr_id']]['value'] = $row['attr_value'];

        }

        else

        {

            $arr['spe'][$row['attr_id']]['attr_type'] = $row['attr_type'];

            $arr['spe'][$row['attr_id']]['name']     = $row['attr_name'];

            $arr['spe'][$row['attr_id']]['values'][] = array(

                                                        'label'        => $row['attr_value'],

                                                        'price'        => $row['attr_price'],

'img_url'        => $row['img_url'],

'img_original'        => $row['img_original'],

'thumb_url'        => $row['thumb_url'],

'hex_color'        => $row['hex_color'],

                                                        'format_price' => price_format(abs($row['attr_price']), false),

                                                        'id'           => $row['goods_attr_id']);

        }

 

        if ($row['is_linked'] == 1)

        {

            /* 如果该属性需要关联,先保存下来 */

            $arr['lnk'][$row['attr_id']]['name']  = $row['attr_name'];

            $arr['lnk'][$row['attr_id']]['value'] = $row['attr_value'];

        }

    }

 

    return $arr;

}

4.关于模板themes/模板路径/goods.dwt修改

{if $value.thumb_url}

<img src="{$value.img_original}" width="50" height="50" alt="{$value.label}" onMouseDown="change_imgb(this.src)">

{elseif $value.hex_color}

<span class="se" style="background:#{$value.hex_color};">&nbsp;</span>

{else}

<span>{$value.label}</span>

{/if}

 

 

 

5.后台执行一下以下语句

在后台数据库管理->SQL查询处执行以下语句:

请将ecs_改成你的网站数据库扩展名,如果你的数据扩展名已经是ecs_了,那就不用改了。

Alter table ecs_goods_attr add column thumb_url varchar(50) not null default '';

Alter table ecs_goods_attr add column img_url varchar(50) not null default '';

Alter table ecs_goods_attr add column img_original varchar(50) not null default '';

Alter table ecs_goods_attr add column hex_color varchar(50) not null default '';

 

工作时间:早9:00—晚上21:00   24H售后:13829351575  服务QQ:292480793  392478192  售后技术QQ:156461982
地址:广东河源市龙川新城开发区5号小区 龙川商耀网络科技有限公司 备案号:粤ICP备15012952号-1
Copyright © 2005-2015 (www.shopsy.cn) All Rights Reserved
在线时间
9:00-22:00