Skip to content

Commit 7b2440a

Browse files
committed
MC-39617: Category Selector limit category upto 5 from the root
- Adding JS code to process the tree
1 parent 661c15c commit 7b2440a

File tree

1 file changed

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

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ $scriptString .= <<<script
7777
dataUrl: '{$block->escapeJs($block->escapeUrl($block->getLoadTreeUrl()))}'
7878
});
7979
80+
categoryLoader.processResponse = function (response, parent, callback) {
81+
var config = JSON.parse(response.responseText);
82+
83+
this.buildCategoryTree(parent, config);
84+
85+
if (typeof callback == "function") {
86+
callback(this, parent);
87+
}
88+
};
89+
8090
categoryLoader.buildCategoryTree = function(parent, config)
8191
{
8292
if (!config) return null;
@@ -164,8 +174,10 @@ $scriptString .= <<<script
164174
};
165175
166176
categoryLoader.on("beforeload", function(treeLoader, node) {
167-
$('{$block->escapeJs($_divId)}').fire('category:beforeLoad', {treeLoader:treeLoader});
168177
treeLoader.baseParams.id = node.attributes.id;
178+
treeLoader.baseParams.store = node.attributes.store;
179+
treeLoader.baseParams.form_key = FORM_KEY;
180+
$('{$block->escapeJs($_divId)}').fire('category:beforeLoad', {treeLoader:treeLoader});
169181
});
170182
171183
tree{$block->escapeJs($block->getId())} = new Ext.tree.TreePanel.Enhanced('{$block->escapeJs($_divId)}', {

0 commit comments

Comments
 (0)