简体   繁体   English

xt:Commerce嵌套集category_left和Categories_right

[英]xt:Commerce nested set categories_left and categories_right

A long time ago, I built an importer for xt:Commerce that worked fine up to v4.1. 很久以前,我为xt:Commerce建立了一个进口商,在v4.1之前都可以正常工作。 The data came from the same PIM system as before. 数据来自与以前相同的PIM系统。

But now, v4.2.0 is out, and they've added a nested set for the categories. 但是现在,v4.2.0已经发布,他们为类别添加了嵌套集。 Anyways that's ok, but they've added two new columns called categories_left and categories_right - and they mess up my importer. 没关系,但是他们添加了两个新列,名为categories_leftcategories_right ,它们使我的导入器混乱。

First of all, I really don't understand what those columns are for. 首先,我真的不明白这些专栏的目的。 My importer works and puts all stuff correctly in the database, but in the frontend, the cats style is broken. 我的导入程序可以正常工作,并将所有内容正确地放入数据库中,但是在前端,cats样式损坏了。 The cause is that my importer sets all cats in those two columns to 0. 原因是我的进口商将这两列中的所有猫都设置为0。

If I add the cats in the backend, it works fine and the frontend style is working. 如果我将猫添加到后端,则可以正常工作,并且前端样式有效。 It seems that these columns are incrementing themselves by 2. 这些列似乎自己增加了2。

categories_id   categories_left   categories_right   parent_id
1               1                 2                  0
2               3                 4                  1
3               5                 6                  1
4               7                 8                  1
5               9                 10                 1

So I implemented a func in the importer that will do exactly the same shown above. 因此,我在导入器中实现了一个功能,该功能与上面显示的功能完全相同。 On the homepage, the frontend style is fine, but if I click on a category the style is broken again. 在主页上,前端样式很好,但是如果我单击类别,则样式又被破坏了。

Could anyone explain what these two columns are for, and how to get this fixed, please? 谁能解释这两列的用途,以及如何解决此问题?

Solution: 解:

Got the answer by myself and built a function that loops through the whole cats. 我自己得到了答案,并建立了遍及整个猫的功能。 This helped me a lot: nested set "Raupe" , full documentation here: wolkekraft Nested Set (german) 这对我很有帮助嵌套集“ Raupe” ,此处的完整文档: wolkekraft嵌套集(德语)

If it is only a manual/one time import, you can leave the columns categories_left and categories_right empty. 如果只是手动/一次性导入,则可以将category_left和category_right列留空。 After the import add a dummy-category in the administration backend. 导入后,在管理后端中添加一个虚拟类别。 When the new category is saved, all categories_left/right columns are recalculated and saved to the database. 保存新类别后,将重新计算所有category_left / right列并将其保存到数据库。

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

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