Skip to content

Commit b77e9a6

Browse files
committed
MAGETWO-90572: Optimize retrieving product attributes
1 parent 6bb5361 commit b77e9a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,14 @@ public function getList($entityTypeCode, \Magento\Framework\Api\SearchCriteriaIn
132132
$attributeCollection->addAttributeGrouping();
133133

134134
$attributes = [];
135-
/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
136-
foreach ($attributeCollection as $attribute) {
137-
$attributes[] = $this->get($entityTypeCode, $attribute->getAttributeCode());
135+
// If search criteria not specified try to load all attributes for speedup
136+
if (!$searchCriteria->getFilterGroups()) {
137+
$attributes = $this->eavConfig->getEntityAttributes($entityTypeCode);
138+
} else {
139+
/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
140+
foreach ($attributeCollection as $attribute) {
141+
$attributes[] = $this->get($entityTypeCode, $attribute->getAttributeCode());
142+
}
138143
}
139144

140145
/** @var \Magento\Eav\Api\Data\AttributeSearchResultsInterface $searchResults */

0 commit comments

Comments
 (0)