Skip to content

Unable to load category checkbox tree #16140

@jwcarder

Description

@jwcarder

Preconditions

  1. Magento 2.2.4 without sample data is installed
  2. Multiple root categories are added (3)
  3. Multiple subcategories added to each root category (2 each)

Steps to reproduce

  1. In Admin, navigate to Marketing-Catalog Price Rule
  2. Add a new rule
  3. Under conditions, add a condition and select Category
  4. Click on the ... link
  5. Click the open chooser button

Expected result

  1. Category checkbox tree loads

Actual result

  1. Category checkbox tree fails to load and script enters an endless loop

After some digging, it appears as though the issue may be in the following file -vendor/magento/module-catalog/view/adminhtml/web/js/category-checkbox-tree.js line 164

categoryLoader.buildCategoryTree = function (parent, config) {// eslint-disable-line no-shadow

                if (!config) {
                    return null;
                }

                if (parent && config && config.length) {
                    for (i = 0; i < config.length; i++) {
                        categoryLoader.processCategoryTree(parent, config, i);
                    }
                }
            };

The counter in the for loop will get a config.length equal to the number of root categories, but will not increment past the number of subcategories contained in the root category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions