Skip to content

Catalog Rule & Selected Categories with level > 3 #17493

@SKovbel

Description

@SKovbel

Preconditions

  1. M 2.1,4

Steps to reproduce

  1. Open form for create new Catalog Rule
  2. In Condition Select^ Product Attribute -> Category
  3. Open Categories Chooser
  4. Select one Category with level = 1, 2 or 3
  5. Select one Category with level > 3 (4, 5, ...)
  6. Click ok & close Category Chooser
  7. Open again Category Chooser and see
    that only categories with level <= 3 are selected
    and category with level > 3 without selection

Expected result

  1. All selected priviosly categories must be selected, with level > 3

Actual result

  1. Categories with level > 3 are not selected

PS

I used M2.1.,4, but checked 2.3 version and this bug is still present.
Categories with level <= 3 are generated with page with level > 3 with ajax request
For myself I fixed in file Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml
2. Added selected param to TreeLoader
3. Change Controller from CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php
to Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php
which can work with selected param
3. After that everything is working

ps
diff

git diff magento/module-catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml
diff --git a/magento/module-catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml b/magento/module-catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml
index b1f81976..af1b9eb1 100644
--- a/magento/module-catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml
+++ b/magento/module-catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml
@@ -73,7 +73,7 @@ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
 jQuery(function()
 {
     var categoryLoader = new Ext.tree.TreeLoader({
-       dataUrl: '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl() ?>'
+       dataUrl: '<?php /* @escapeNotVerified */ echo $block->getUrl('catalog/category_widget/categoriesJson') ?>'
     });
 
     categoryLoader.createNode = function(config) {
@@ -146,6 +146,7 @@ jQuery(function()
 
     categoryLoader.on("beforeload", function(treeLoader, node) {
         treeLoader.baseParams.id = node.attributes.id;
+        treeLoader.baseParams.selected = <?php /* @escapeNotVerified */ echo $block->getJsFormObject() ?>.updateElement.value;
     });
 
     categoryLoader.on("load", function(treeLoader, node, config) {

screenshot from 2018-08-10 16-36-43

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CatalogRuleFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions