magento直接运行如下sql语句,,即可得到。。然后自己保存下就行了。。。效果如下: +-------------------+------------+ | sku | categories | +-------------------+------------+ | 1111 | 22 | | 1112 | 22 | | 1113 | 22 | | 1114 | 22 | | 1gbdimm | 15,31 | | 1tb7200 | 29 | | 226bw | 30 | | 250gb5400 | 29 | | 2gbdimm | 15,31 | | 384822 | 23 | | 4fasd5f5 | 19 | | 500gb5400 | 29 | | 500gb7200 | 29 | | 512dimm | 15,31 | | 750 | 12,26 | | 8525PDA | 8 | +-------------------+------------+ 这里的GROUP_CONCAT()函数少见但有用,它可以把多行记录,合并成一行。这在SQL中通常称为:行转列。 select c.sku ,GROUP_CONCAT(p.category_id SEPARATOR ',') as categories from catalog_product_entity as c inner join catalog_category_product as p on c.entity_id = p.product_id group by c.sku;(责任编辑:最模板) |