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;
 }
Exemple #2
0
 /**
  * Return a collection with with products that match the category rules loaded.
  *
  * @return \Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection
  */
 private function getAutomaticSortProductCollection()
 {
     $productCollection = $this->productCollectionFactory->create();
     $productCollection->setStoreId($this->category->getStoreId())->addQueryFilter($this->getQueryFilter())->addAttributeToSelect(['name', 'small_image']);
     return $productCollection;
 }