ecshop 获得某个商品类型下面的所有属性,前提是某个分类下面只能用某个商品属性,而且属性值都是输入
goods_type 要对应商品分类 cat_id
cat_id
|
|- `ecs_attribute` `cat_id`` attr_id`
|-ecs_goods_attr `attr_id``attr_value``goods_id`
select cat_id from goods_type cat_name='测试'
111
select attr_name, attr_id,cat_id from ecs_attribute where cat_id=111
select a.*, b.attr_name,b.cat_id as goods_type_id
from
(SELECT a.attr_id, MIN(a.goods_attr_id ) AS goods_id, a.attr_value AS attr_value
FROM `ecshop1_2xc`.`ecs_goods_attr` AS a, `ecshop1_2xc`.`ecs_goods` AS g WHERE (g.cat_id IN ('517') OR g.goods_id IN ('') )
AND g.goods_id = a.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 GROUP BY a.attr_value) a
left join ecs_attribute b on b.cat_id=111 and a.attr_id = b.attr_id order by b.attr_name