Skip to content

Commit

Permalink
replace hardcode category root id number with Category THE_ROOT_ID
Browse files Browse the repository at this point in the history
…const
  • Loading branch information
mhhansen committed Jul 19, 2018
1 parent 10afe1d commit 0ba4b71
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\CatalogGraphQl\Model\AttributesJoiner;
use Magento\Catalog\Model\Category;

/**
* Category tree data provider
Expand Down Expand Up @@ -96,7 +97,7 @@ public function getTree(ResolveInfo $resolveInfo, int $rootCategoryId) : array
$level = $this->levelCalculator->calculate($rootCategoryId);

// If root category is being filter, we've to remove first slash
if ($rootCategoryId == 1) {
if ($rootCategoryId == Category::TREE_ROOT_ID) {
$regExpPathFilter = sprintf('.*%s/[/0-9]*$', $rootCategoryId);
} else {
$regExpPathFilter = sprintf('.*/%s/[/0-9]*$', $rootCategoryId);
Expand Down

0 comments on commit 0ba4b71

Please sign in to comment.