11 use Magento\Catalog\Api\Data\CategorySearchResultsInterfaceFactory;
13 use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
23 private $categoryCollectionFactory;
28 private $extensionAttributesJoinProcessor;
33 private $categorySearchResultsFactory;
38 private $categoryRepository;
43 private $collectionProcessor;
53 CollectionFactory $categoryCollectionFactory,
55 CategorySearchResultsInterfaceFactory $categorySearchResultsFactory,
59 $this->categoryCollectionFactory = $categoryCollectionFactory;
60 $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
61 $this->categorySearchResultsFactory = $categorySearchResultsFactory;
63 $this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
72 $collection = $this->categoryCollectionFactory->create();
73 $this->extensionAttributesJoinProcessor->process(
$collection);
79 $items[] = $this->categoryRepository->get(
$id);
83 $searchResult = $this->categorySearchResultsFactory->create();
85 $searchResult->setItems(
$items);
86 $searchResult->setTotalCount(
$collection->getSize());
96 private function getCollectionProcessor()
98 if (!$this->collectionProcessor) {
100 'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor' 103 return $this->collectionProcessor;
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
__construct(CollectionFactory $categoryCollectionFactory, JoinProcessorInterface $extensionAttributesJoinProcessor, CategorySearchResultsInterfaceFactory $categorySearchResultsFactory, CategoryRepositoryInterface $categoryRepository, CollectionProcessorInterface $collectionProcessor=null)