加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

php-将Magento种别复制到怙恃

发布时间:2021-01-24 22:58:19 所属栏目:编程 来源:网络整理
导读:场景: 一个带有种别产物和客户导入的新空缺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_child

场景:
一个带有种别产物和客户导入的新空缺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).可是,最大的题目是,您祈望的功效现实上使项目标碰撞水平高出了一个级别,而此查询仅执行了一个级别.为了真正正确地归纳综合,可以将此查询放入一些代码中,并从最低深度??开始一再并向上移动.

但愿有辅佐!

感谢,

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读