ecshop商品属性排序的问题和解决方法
发布:smiling 来源: PHP粉丝网 添加日期:2014-11-18 09:53:43 浏览: 评论:0
情况一:添加新产品时,让属性按照添加的顺序(属性id)排列,修改/inclues/lib_goods.php:
- $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:
- 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))
- { //开源软件:phpfensi.com
- $attr_list[$goods_attr['attr_id']]['goods_attr_list'][$goods_attr['goods_attr_id']] = $goods_attr['attr_value'];
- }
- return $attr_list;
- }
补充:上面说的是同一属性里属性值的排序.
Tags: ecshop商品属性 ecshop商品排序
相关文章
- ·ecshop获取输出商品属性的值的方法(2014-12-04)
- ·ecshop jquery冲突,美化商品属性选择 IE中js无法获得默认属性(2015-12-07)
- ·商品相册显示顺序为正序实现方法(2014-11-18)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)