联创互动 | 湖南建站专家 - 企业网络营销战略伙伴
7×24小时业务咨询热线:13786157601

技术文档

ecshop商品属性排序的问题

时间:2011-12-30 10:03来源:未知 作者:admin 点击:


情况一:添加新产品时,让属性按照添加的顺序(属性id)排列
修改/inclues/lib_goods.php 找到631行

    /* 获得商品的规格 */
    $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 g.goods_attr_id, a.sort_order, g.attr_price';
    $res = $GLOBALS['db']->getAll($sql);

情况二:在复制商品时属性排序跟原商品相反到处理
修改/inclues/lib_goods.php
/**
* 取得商品属性
* @param   int     $goods_id   商品id
* @return  array
*/
function get_goods_attr($goods_id)
{
    $attr_list = array();
    $sql = "SELECT a.attr_id, a.attr_name " .
            "FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('attribute') . " AS a " .
            "WHERE g.goods_id = '$goods_id' " .
            "AND g.goods_type = a.cat_id " .
            "AND a.attr_type = 1".' ORDER BY a.attr_id';
    $attr_id_list = $GLOBALS['db']->getCol($sql);
    $res = $GLOBALS['db']->query($sql);
    while ($attr = $GLOBALS['db']->fetchRow($res))
    {
        if (defined('ECS_ADMIN'))
        {
            $attr['goods_attr_list'] = array(0 => $GLOBALS['_LANG']['select_please']);
        }
        else
        {
            $attr['goods_attr_list'] = array();
        }
        $attr_list[$attr['attr_id']] = $attr;
    }
    $sql = "SELECT attr_id, goods_attr_id, attr_value " .
            "FROM " . $GLOBALS['ecs']->table('goods_attr') .
            " WHERE goods_id = '$goods_id' " .
            "AND attr_id " . db_create_in($attr_id_list).' ORDER BY goods_attr_id';
    $res = $GLOBALS['db']->query($sql);
    while ($goods_attr = $GLOBALS['db']->fetchRow($res))
    {
        $attr_list[$goods_attr['attr_id']]['goods_attr_list'][$goods_attr['goods_attr_id']] = $goods_attr['attr_value'];
    }
    return $attr_list;
}

补充:上面说的是同一属性里属性值的排序
 

(责任编辑:admin)
关键词:ecshop商品属性排序的问题
------分隔线----------------------------

最新案例

更多>>

客服中心

联创首页 长沙网站建设 虚拟主机 域名注册 客户案例 关于联创 网站地图 联系联创
Copyright © 2007-2010 Leneweb, All Rights Reserved
湖南联创互动2010版 Www.Leneweb.Com 版权所有
关键词:湖南网站建设|网络外包|湖南网站建设案例|整合营销|长沙网站制作|湖南网站制作案例|营销型网站建设|长沙营销型网站建设|湖南营销型网站建设|长沙空间域名