File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/CategoryTree/Wrapper Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 16
16
*/
17
17
class Forgery
18
18
{
19
+ /**
20
+ * Most top node id in the tree structure.
21
+ */
22
+ private const DUMMY_ROOT_ID = 0 ;
23
+
19
24
/**
20
25
* Flat index of the tree.
21
26
*
@@ -50,9 +55,12 @@ function ($element) {
50
55
},
51
56
explode ('/ ' , $ category ->getPath ())
52
57
);
53
- $ parentId = null ;
58
+ if (!$ this ->hasNodeById (self ::DUMMY_ROOT_ID )) {
59
+ $ this ->indexById [self ::DUMMY_ROOT_ID ] = new Node (self ::DUMMY_ROOT_ID , $ this );
60
+ }
61
+ $ parentId = self ::DUMMY_ROOT_ID ;
54
62
foreach ($ pathElements as $ id ) {
55
- if ($ parentId && $ this ->hasNodeById ($ parentId )) {
63
+ if ($ this ->hasNodeById ($ parentId )) {
56
64
if (!$ this ->hasNodeById ($ id )) {
57
65
$ this ->indexById [$ id ] = new Node ($ id , $ this );
58
66
$ this ->getNodeById ($ parentId )->addChild ($ this ->indexById [$ id ]);
You can’t perform that action at this time.
0 commit comments