场景:
一个带有类别产品和客户导入的新空白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..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).但是,最大的问题是,您期望的结果实际上使项目的碰撞程度超过了一个级别,而此查询仅执行了一个级别.为了真正正确地概括,可以将此查询放入一些代码中,并从最低深度开始重复并向上移动.
希望有帮助!
谢谢,
乔
标签:magento,mysql,php 来源: https://codeday.me/bug/20191209/2096763.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。