简体   繁体   English

Magento:将产品(分组)类别分配给构建它的所有简单产品

[英]Magento: assign product (grouped) category to all simple product that build it

I have 8000 simple products without category assigned. 我有8000个未分配类别的简单产品

These simple products are used to create a lot some grouped products . 这些简单的产品用于创建许多分组产品

All grouped product have category assigned. 所有分组的产品均已分配类别。

Is possible to assign grouped product category to all simple products that are associated to it? 是否可以将分组的产品类别分配给与其关联的所有简单产品?

you could just try to add entries to catalog_category_product table..: 您可以尝试将条目添加到catalog_category_product表..:

INSERT IGNORE INTO catalog_category_product (category_id, product_id)
SELECT ccp.category_id, cpr.child_id FROM catalog_product_entity  cpe
JOIN catalog_product_relation cpr ON cpr.parent_id = cpe.entity_id
JOIN catalog_category_product ccp ON cpe.entity_id = ccp.product_id
WHERE cpe.type_id = 'grouped'
ORDER BY cpe.entity_id
;

following SQL will add all simple products which are associated with any grouped products to all categories to which the grouped product is assigned. 下列SQL会将与任何分组产品关联的所有简单产品添加到分配了分组产品的所有类别中。 I wrote in just now and didn't test it so be sure to test it before launching on PRODUCTION db;-) 我刚才写的内容并未进行测试,因此请确保在PRODUCTION db上启动之前进行测试;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM