Skip to content

Commit cc11721

Browse files
author
Yaroslav Onischenko
committed
Merge remote-tracking branch 'origin/MAGETWO-56356' into SEGFAULT_BANNERS_PR
2 parents ae53ec1 + 0ff69c5 commit cc11721

File tree

10 files changed

+747
-98
lines changed

10 files changed

+747
-98
lines changed

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class DataProvider
9494
*/
9595
private $metadata;
9696

97+
/**
98+
* @var array
99+
*/
100+
private $attributeOptions = [];
101+
97102
/**
98103
* @param ResourceConnection $resource
99104
* @param \Magento\Catalog\Model\Product\Type $catalogProductType
@@ -177,23 +182,13 @@ public function getSearchableProducts(
177182
return $result;
178183
}
179184

180-
/**
181-
* Retrieve EAV Config Singleton
182-
*
183-
* @return \Magento\Eav\Model\Config
184-
*/
185-
private function getEavConfig()
186-
{
187-
return $this->eavConfig;
188-
}
189-
190185
/**
191186
* Retrieve searchable attributes
192187
*
193188
* @param string $backendType
194189
* @return \Magento\Eav\Model\Entity\Attribute[]
195190
*/
196-
private function getSearchableAttributes($backendType = null)
191+
public function getSearchableAttributes($backendType = null)
197192
{
198193
if (null === $this->searchableAttributes) {
199194
$this->searchableAttributes = [];
@@ -210,7 +205,7 @@ private function getSearchableAttributes($backendType = null)
210205
['engine' => $this->engine, 'attributes' => $attributes]
211206
);
212207

213-
$entity = $this->getEavConfig()->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getEntity();
208+
$entity = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getEntity();
214209

215210
foreach ($attributes as $attribute) {
216211
$attribute->setEntity($entity);
@@ -239,7 +234,7 @@ private function getSearchableAttributes($backendType = null)
239234
* @param int|string $attribute
240235
* @return \Magento\Eav\Model\Entity\Attribute
241236
*/
242-
private function getSearchableAttribute($attribute)
237+
public function getSearchableAttribute($attribute)
243238
{
244239
$attributes = $this->getSearchableAttributes();
245240
if (is_numeric($attribute)) {
@@ -254,7 +249,7 @@ private function getSearchableAttribute($attribute)
254249
}
255250
}
256251

257-
return $this->getEavConfig()->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attribute);
252+
return $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attribute);
258253
}
259254

260255
/**
@@ -487,11 +482,21 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
487482
&& $attribute->usesSource()
488483
&& $this->engine->allowAdvancedIndex()
489484
) {
490-
$attribute->setStoreId($storeId);
485+
if (!isset($this->attributeOptions[$attributeId][$storeId])) {
486+
$attribute->setStoreId($storeId);
487+
$options = $attribute->getSource()->toOptionArray();
488+
$this->attributeOptions[$attributeId][$storeId] = array_combine(
489+
array_column($options, 'value'),
490+
array_column($options, 'label')
491+
);
492+
}
491493

492-
$valueText = (array) $attribute->getSource()->getIndexOptionText($valueId);
494+
$valueText = '';
495+
if (isset($this->attributeOptions[$attributeId][$storeId][$valueId])) {
496+
$valueText = $this->attributeOptions[$attributeId][$storeId][$valueId];
497+
}
493498

494-
$pieces = array_filter(array_merge([$value], $valueText));
499+
$pieces = array_filter(array_merge([$value], [$valueText]));
495500

496501
$value = implode($this->separator, $pieces);
497502
}

0 commit comments

Comments
 (0)