Skip to content

Commit

Permalink
Merge pull request #900 from romainruaud/fix_cross-tree-category-root
Browse files Browse the repository at this point in the history
Prevent assigning a cross-tree virtual category root.
  • Loading branch information
afoucret authored May 7, 2018
2 parents 40b7a58 + e4c487d commit 5d8cc7a
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function create(array $data = [])

if ($this->getCurrentCategory() && $this->getCurrentCategory()->getLevel() >= 2) {
$collection->addAttributeToFilter('entity_id', ['neq' => (int) $this->getCurrentCategory()->getId()]);

$rootPath = array_slice($this->getCurrentCategory()->getPathIds(), 0, 2);
$pathCondition = implode('/', $rootPath) . '%';
$collection->addFieldToFilter('path', ['like' => $pathCondition]);
}

return $collection;
Expand Down

0 comments on commit 5d8cc7a

Please sign in to comment.