From 9f19592b3a1dc33a8a3a23c694880e5e6c5ca6a3 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolowski Date: Mon, 10 Sep 2018 13:12:15 +0200 Subject: [PATCH] Fix category tree in cart price rule #17493 --- .../Catalog/view/adminhtml/web/js/category-checkbox-tree.js | 1 + .../Controller/Adminhtml/Promo/Widget/CategoriesJson.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js b/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js index 72cad03eabe1b..1d64418e36ff5 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js @@ -230,6 +230,7 @@ define([ categoryLoader.on('beforeload', function (treeLoader, node) { treeLoader.baseParams.id = node.attributes.id; + treeLoader.baseParams.selected = options.jsFormObject.updateElement.value; }); /* eslint-disable */ diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php index d049d74bd2601..3d1ac9744ef8b 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php @@ -77,10 +77,11 @@ public function execute() if (!($category = $this->_initCategory())) { return; } + $selected = $this->getRequest()->getPost('selected', ''); $block = $this->_view->getLayout()->createBlock( \Magento\Catalog\Block\Adminhtml\Category\Checkboxes\Tree::class )->setCategoryIds( - [$categoryId] + explode(',', $selected) ); $this->getResponse()->representJson( $block->getTreeJson($category)