Skip to content

Commit 024a648

Browse files
committed
ACP2E-3131: [Cloud] Anchor/Non-Anchor Categories Reversed in Content Widget
- Fix for default category
1 parent 0e6bad0 commit 024a648

File tree

1 file changed

+10
-17
lines changed
  • app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget

1 file changed

+10
-17
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ require(['jquery', 'jquery/jstree/jquery.jstree'], function($) {
6161
6262
data.instance.get_json('#', { flat: true }).forEach(nodeId => {
6363
const node = data.instance.get_node(nodeId);
64-
isAnchorArr[parseInt(node.id)] = node.original.is_anchor;
65-
if (checkedNodes.includes(node.id)) {
66-
tree.jstree(true).select_node(node.id);
67-
}
68-
69-
actionBasedOnIsAnchorOnly();
64+
getAnchorNodeIds(tree, node);
7065
});
7166
}
7267
@@ -134,12 +129,9 @@ require(['jquery', 'jquery/jstree/jquery.jstree'], function($) {
134129
// Create the new node and execute node callback
135130
data.instance.create_node(childNode, newNode, 'last', node => {
136131
if (useMassAction) {
137-
isAnchorArr[parseInt(node.id)] = node.original.is_anchor;
138-
if (checkedNodes.includes(node.id)) {
139-
tree.jstree(true).select_node(node.id);
132+
if ($.inArray(childNode.id, isAnchorArr) === -1) {
133+
getAnchorNodeIds(tree, childNode);
140134
}
141-
getCheckedNodeIds(tree, node);
142-
actionBasedOnIsAnchorOnly();
143135
}
144136
});
145137
});
@@ -151,6 +143,9 @@ require(['jquery', 'jquery/jstree/jquery.jstree'], function($) {
151143
if (parentNode && parentNode.children.length > 0) {
152144
parentNode.children.forEach(function(childId) {
153145
let childNode = data.instance.get_node(childId, false);
146+
if ($.inArray(childNode.id, isAnchorArr) === -1) {
147+
getAnchorNodeIds(tree, childNode);
148+
}
154149
// Check if the child node has no children (is not yet loaded)
155150
if (childNode.children && childNode.children.length === 0
156151
&& childNode.original && !childNode.original.lastNode) {
@@ -171,14 +166,12 @@ require(['jquery', 'jquery/jstree/jquery.jstree'], function($) {
171166
}
172167
});
173168
}
174-
else if ((childNode.children.length === 0
175-
&& childNode.original && childNode.original.lastNode)
176-
|| childNode.children.length === 1) {
177-
178-
getAnchorNodeIds(tree, childNode);
179-
}
180169
})
181170
}
171+
else if ((parentNode.children.length === 0
172+
&& parentNode.original && parentNode.original.lastNode)) {
173+
getAnchorNodeIds(tree, parentNode);
174+
}
182175
}
183176
184177
var jstreeConfig = {

0 commit comments

Comments
 (0)