diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php index c6c6f6b6686dd..fb9a53b422ba9 100644 --- a/app/code/Magento/Eav/Model/AttributeSetRepository.php +++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php @@ -105,6 +105,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr $collection->setEntityTypeFilter($this->eavConfig->getEntityType($entityTypeCode)->getId()); } + foreach ($searchCriteria->getFilterGroups() as $group) { + $this->addFilterGroupToCollection($group, $collection); + } + $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); @@ -115,6 +119,29 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr return $searchResults; } + /** + * Helper function that adds a FilterGroup to the collection. + * + * @deprecated already removed in 2.2-develop. Use CollectionProcessorInterface to process search criteria + * + * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup + * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection + * @return void + */ + protected function addFilterGroupToCollection( + \Magento\Framework\Api\Search\FilterGroup $filterGroup, + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection + ) { + foreach ($filterGroup->getFilters() as $filter) { + /** entity type filter is already set on collection */ + if ($filter->getField() === 'entity_type_code') { + continue; + } + $conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; + $collection->addFieldToFilter($filter->getField(), [$conditionType, $filter->getValue()]); + } + } + /** * Retrieve entity type code from search criteria *