Skip to content

Commit 8e00c97

Browse files
ENGCOM-6232: Elastic Search 5 Indexing Performance Issue with product mapper #25452
2 parents 87b0a4b + 8cb8d77 commit 8e00c97

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,14 @@ private function prepareAttributeValues(
272272
*/
273273
private function prepareMultiselectValues(array $values): array
274274
{
275-
return \array_merge(...\array_map(function (string $value) {
276-
return \explode(',', $value);
277-
}, $values));
275+
return \array_merge(
276+
...\array_map(
277+
function (string $value) {
278+
return \explode(',', $value);
279+
},
280+
$values
281+
)
282+
);
278283
}
279284

280285
/**
@@ -305,9 +310,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
305310
return $attributeLabels;
306311
}
307312

308-
foreach ($options as $option) {
309-
if (\in_array($option->getValue(), $attributeValues)) {
310-
$attributeLabels[] = $option->getLabel();
313+
foreach ($attributeValues as $attributeValue) {
314+
if (isset($options[$attributeValue])) {
315+
$attributeLabels[] = $options[$attributeValue]->getLabel();
311316
}
312317
}
313318

@@ -324,7 +329,11 @@ private function getAttributeOptions(Attribute $attribute): array
324329
{
325330
if (!isset($this->attributeOptionsCache[$attribute->getId()])) {
326331
$options = $attribute->getOptions() ?? [];
327-
$this->attributeOptionsCache[$attribute->getId()] = $options;
332+
$optionsByValue = [];
333+
foreach ($options as $option) {
334+
$optionsByValue[$option->getValue()] = $option;
335+
}
336+
$this->attributeOptionsCache[$attribute->getId()] = $optionsByValue;
328337
}
329338

330339
return $this->attributeOptionsCache[$attribute->getId()];

0 commit comments

Comments
 (0)