Php 将Magento类别复制到父级
情景: 一个新的空白Magento与一个类别的产品和客户导入与一些修复做 类别结构:Php 将Magento类别复制到父级,php,mysql,magento,Php,Mysql,Magento,情景: 一个新的空白Magento与一个类别的产品和客户导入与一些修复做 类别结构: Root L..Category_parent1 (0 products) L..Category_child1 (22) L..Category_child2 (34) L..Category_parent2 (0) L..Category_child1 (22) L..Category_child2 (34) L..Category_parent3 (0) L.
Root
L..Category_parent1 (0 products)
L..Category_child1 (22)
L..Category_child2 (34)
L..Category_parent2 (0)
L..Category_child1 (22)
L..Category_child2 (34)
L..Category_parent3 (0)
L..Category_child1 (22)
L..Category_child2 (0)
L..Category_child2_child1 (22)
L..Category_child2_child2 (34)
L..Category_child3 (10)
我想使用SQL查询或php脚本将所有产品从子类别复制到其相对父类别。(我不知道是否可以通过Magento管理员进行此操作)
预期结果:
Root
L..Category_parent1 (22 + 34 products)
L..Category_child1 (22)
L..Category_child2 (34)
L..Category_parent2 (22 + 34)
L..Category_child1 (22)
L..Category_child2 (34)
L..Category_parent3 (22 + 22 + 34 + 10)
L..Category_child1 (22)
L..Category_child2 (22 + 34)
L..Category_child2_child1 (22)
L..Category_child2_child2 (34)
L..Category_child3 (10)
更新!
有没有办法只在展示产品上做到这一点?
以这种方式查看产品,使其与自己的类别保持联系(只需在列表中的视图布局中进行此操作…?作为部分解决方案:
insert into catalog_category_product_index (
select cat.parent_id, prod.product_id, 1
from catalog_category_product_index prod, catalog_category_entity cat
where prod.category_id = cat.entity_id and cat.level >= 1
);
这将选择所有内容并将其提升一个级别(直到我们找到根)。单独的查询将有助于定位列(当前硬编码为1)。不过,最大的问题是,您所期望的结果实际上会将项目颠簸到多个级别,而此查询只执行一个级别。要真正正确地概括,可以将此查询放入一些代码中,从最低深度开始重复,然后向上移动
希望有帮助
谢谢,
Joe似乎设置所有类别都能解决我的问题,但joseph提供的答案回答了有效的问题,但我认为最好在查看模式下这样做(出于某些实际原因:将所有产品(删除类别)移动到一个类别中,而不必关心该产品的放置位置)