Skip to content

Commit 8cb8d77

Browse files
ENGCOM-6232: Elastic Search 5 Indexing Performance Issue with product mapper #25452
- Merge Pull Request #25452 from behnamshayani/magento2:bugfix/elastic-product-mapper-performance-fix - Merged commits: 1. df50692 2. 1a0cae2 3. d1c848f 4. 0bf7a4c 5. 2b5b986
2 parents dac1ea5 + 2b5b986 commit 8cb8d77

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
@@ -252,9 +252,14 @@ private function prepareAttributeValues(
252252
*/
253253
private function prepareMultiselectValues(array $values): array
254254
{
255-
return \array_merge(...\array_map(function (string $value) {
256-
return \explode(',', $value);
257-
}, $values));
255+
return \array_merge(
256+
...\array_map(
257+
function (string $value) {
258+
return \explode(',', $value);
259+
},
260+
$values
261+
)
262+
);
258263
}
259264

260265
/**
@@ -285,9 +290,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
285290
return $attributeLabels;
286291
}
287292

288-
foreach ($options as $option) {
289-
if (\in_array($option->getValue(), $attributeValues)) {
290-
$attributeLabels[] = $option->getLabel();
293+
foreach ($attributeValues as $attributeValue) {
294+
if (isset($options[$attributeValue])) {
295+
$attributeLabels[] = $options[$attributeValue]->getLabel();
291296
}
292297
}
293298

@@ -304,7 +309,11 @@ private function getAttributeOptions(Attribute $attribute): array
304309
{
305310
if (!isset($this->attributeOptionsCache[$attribute->getId()])) {
306311
$options = $attribute->getOptions() ?? [];
307-
$this->attributeOptionsCache[$attribute->getId()] = $options;
312+
$optionsByValue = [];
313+
foreach ($options as $option) {
314+
$optionsByValue[$option->getValue()] = $option;
315+
}
316+
$this->attributeOptionsCache[$attribute->getId()] = $optionsByValue;
308317
}
309318

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

0 commit comments

Comments
 (0)