将类别从父级可配置产品复制到Magento中的简单子级产品 [英] Copy categories from parent configurable product to simple child product in Magento

查看:95
本文介绍了将类别从父级可配置产品复制到Magento中的简单子级产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些建议,以最佳方式以编程方式对此进行存档.

I need some advise on best way to archieve this programmatically.

问题是我有许多可配置的产品(+20.000),它们已经在一个类别中.所有简单的底层儿童产品根本不在任何类别中.我希望所有简单的子产品都可以继承父产品的类别.

The problem is that i have many configurable prodcuts (+20.000) which are allready in a category. All the simple underlaying child products are not in any category at all. I want all simple child products to inherit category from parent.

如果可配置产品"A"在名为类别A"的类别中,则产品"A"的所有子产品都应包括在类别A"中.

If configurable product "A" is in category called "Category A", all child products of product "A" should be included in "Category A".

这将用于XML产品Feed,因此我无法在Magento中使用锚点类别.

This is going to used for an XML product feed, so i can not use anchor categories in Magento.

有人建议如何进行归档,还要考虑需要在数据库中更新的SKU数量?

Any advise on how to archieve this, also considering the amounts of SKU's that needs to be updated in database?

推荐答案

我们遇到了同样的问题.该查询将通过抓住每个可配置产品的子级,并为每个子级插入一个新的类别关联(每个父级类别一个)来填补空白

We had this same problem. This query will fill in the gaps by grabbing each configurable product's children, and inserting a new category association for each one (one for each of the parent categories)

INSERT IGNORE INTO catalog_category_product (category_id, product_id) SELECT ccp.category_id, cpl.product_id FROM catalog_product_super_link cpl LEFT JOIN catalog_category_product ccp ON ccp.product_id = cpl.parent_id WHERE ccp.category_id IN (SELECT entity_id FROM catalog_category_entity);

INSERT IGNORE INTO catalog_category_product (category_id, product_id) SELECT ccp.category_id, cpl.product_id FROM catalog_product_super_link cpl LEFT JOIN catalog_category_product ccp ON ccp.product_id = cpl.parent_id WHERE ccp.category_id IN (SELECT entity_id FROM catalog_category_entity);

注意:最后的WHERE子句是为了防止外键错误.

Note: The WHERE clause at the end is to prevent foreign key errors.

这篇关于将类别从父级可配置产品复制到Magento中的简单子级产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆