Skip to content

Commit 6862394

Browse files
author
David
committed
[BUGFIX][11022] process search criteria fields on eav collection
1 parent 525f90a commit 6862394

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

app/code/Magento/Eav/Model/AttributeSetRepository.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
105105
$collection->setEntityTypeFilter($this->eavConfig->getEntityType($entityTypeCode)->getId());
106106
}
107107

108+
foreach ($searchCriteria->getFilterGroups() as $group) {
109+
$this->addFilterGroupToCollection($group, $collection);
110+
}
111+
108112
$collection->setCurPage($searchCriteria->getCurrentPage());
109113
$collection->setPageSize($searchCriteria->getPageSize());
110114

@@ -115,6 +119,29 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
115119
return $searchResults;
116120
}
117121

122+
/**
123+
* Helper function that adds a FilterGroup to the collection.
124+
*
125+
* @deprecated already removed in 2.2-develop. Use CollectionProcessorInterface to process search criteria
126+
*
127+
* @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
128+
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection
129+
* @return void
130+
*/
131+
protected function addFilterGroupToCollection(
132+
\Magento\Framework\Api\Search\FilterGroup $filterGroup,
133+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection
134+
) {
135+
foreach ($filterGroup->getFilters() as $filter) {
136+
/** entity type filter is already set on collection */
137+
if ($filter->getField() === 'entity_type_code') {
138+
continue;
139+
}
140+
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
141+
$collection->addFieldToFilter($filter->getField(), [$conditionType, $filter->getValue()]);
142+
}
143+
}
144+
118145
/**
119146
* Retrieve entity type code from search criteria
120147
*

0 commit comments

Comments
 (0)