EC商品属性规格的按价格排序,为什么只按第一个数字排啊

2016-07-07 15:35 来源:www.chinab4c.com 作者:ecshop专家

EC商品属性规格的按价格排序,为什么只按第一个数字排啊,比如
2G 100元
4G 200元
8G 400元
1G 50元
16G 800元

代码是:
/* 获得商品的规格 */
$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.attr_price, g.goods_attr_id, a.sort_order, ' ;

回答:
主要问题出在红色这部分:
/* 获得商品的规格 */
$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.attr_price, g.goods_attr_id, a.sort_order, ' ;

调整g.attr_price, g.goods_attr_id, a.sort_order, 这几个参数的位置看看就知道为什么了