Exemple #1
0
 /**
  * Returns the list of the virtual categories available under a category.
  *
  * @param CategoryInterface $category           Category.
  * @param array             $excludedCategories Category already used into the building stack. Avoid short circuit.
  *
  * @return \Magento\Catalog\Model\ResourceModel\Category\Collection;
  */
 private function getChildrenVirtualCategories(CategoryInterface $category, $excludedCategories = [])
 {
     $storeId = $category->getStoreId();
     $categoryCollection = $this->categoryCollectionFactory->create()->setStoreId($storeId);
     $categoryCollection->addAttributeToFilter('is_virtual_category', 1)->addAttributeToFilter('is_active', ['neq' => 0])->addPathFilter(sprintf('%s/.*', $category->getPath()));
     if (!empty($excludedCategories)) {
         $categoryCollection->addAttributeToFilter('entity_id', ['nin' => $excludedCategories]);
     }
     $categoryCollection->addAttributeToSelect(['is_active', 'virtual_category_root', 'is_virtual_category', 'virtual_rule']);
     return $categoryCollection;
 }