Skip to content

Commit

Permalink
[BUGFIX][11022] process search criteria fields on eav collection
Browse files Browse the repository at this point in the history
  • Loading branch information
David committed Nov 3, 2017
1 parent 525f90a commit 6862394
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/code/Magento/Eav/Model/AttributeSetRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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
*
Expand Down

0 comments on commit 6862394

Please sign in to comment.