Skip to content

Commit 40b5cd7

Browse files
committed
ACP2E-3136: [Cloud] Sub Category items are not displayed on the widgets edit on the admin backend
1 parent 93d50f8 commit 40b5cd7

File tree

1 file changed

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

1 file changed

+30
-26
lines changed

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

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
7+
/**
8+
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9+
* @var \Magento\Framework\Escaper $escaper
10+
*/
811
?>
912

1013
<?php $_divId = 'tree' . $block->getId() ?>
11-
<div id="<?= $block->escapeHtmlAttr($_divId) ?>" class="tree"></div>
14+
<div id="<?= $escaper->escapeHtmlAttr($_divId) ?>" class="tree"></div>
1215
<?php
1316
$isUseMassAction = $block->getUseMassaction() ? 1 : 0;
1417
$isAnchorOnly = $block->getIsAnchorOnly() ? 1 : 0;
@@ -124,29 +127,30 @@ require(['jquery', 'jquery/jstree/jquery.jstree'], function($) {
124127
125128
function handleOpenNode(e, data) {
126129
let parentNode = data.node;
127-
128-
if (parentNode.children.length > 0) {
129-
let childNode = data.instance.get_node(parentNode.children, false);
130-
131-
// Check if the child node has no children (is not yet loaded)
132-
if (childNode.children && childNode.children.length === 0
133-
&& childNode.original && !childNode.original.lastNode) {
134-
$.ajax({
135-
url: '{$block->escapeJs($block->escapeUrl($block->getLoadTreeUrl()))}',
136-
data: {
137-
id: childNode.original.id,
138-
store: childNode.original.store,
139-
form_key: FORM_KEY
140-
},
141-
dataType: 'json',
142-
success: function (response) {
143-
handleSuccessResponse(response, childNode, data);
144-
},
145-
error: function (jqXHR, status, error) {
146-
console.log(status + ': ' + error + 'Response text:' + jqXHR.responseText);
147-
}
148-
});
149-
}
130+
if (parentNode && parentNode.children.length > 0) {
131+
parentNode.children.forEach(function(childId) {
132+
let childNode = data.instance.get_node(childId, false);
133+
// Check if the child node has no children (is not yet loaded)
134+
if (childNode.children && childNode.children.length === 0
135+
&& childNode.original && !childNode.original.lastNode) {
136+
$.ajax({
137+
url: '{$block->escapeJs($block->escapeUrl($block->getLoadTreeUrl()))}',
138+
type: "POST",
139+
data: {
140+
id: childNode.original.id,
141+
store: childNode.original.store,
142+
form_key: FORM_KEY
143+
},
144+
dataType: 'json',
145+
success: function (response) {
146+
handleSuccessResponse(response, childNode, data);
147+
},
148+
error: function (jqXHR, status, error) {
149+
console.log(status + ': ' + error + 'Response text:' + jqXHR.responseText);
150+
}
151+
});
152+
}
153+
})
150154
}
151155
}
152156
@@ -179,7 +183,7 @@ script;
179183
?>
180184
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
181185
'overflow-x: auto;',
182-
'#tree' . $block->escapeJs($block->getId())
186+
'#tree' . $escaper->escapeJs($block->getId())
183187
);
184188
?>
185189
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>

0 commit comments

Comments
 (0)