Skip to content

Commit 859e614

Browse files
freddenihor-sviziev
authored andcommitted
Improve readibility
Co-authored-by: Ihor Sviziev <ihor-sviziev@users.noreply.github.com>
1 parent d5a2fb6 commit 859e614

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,14 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues, i
370370
return $attributeLabels;
371371
}
372372

373-
$options = array_intersect_key($options, array_flip($attributeValues));
374-
$attributeLabels = array_column($options, 'label');
373+
// array_flip() + foreach { isset() } is much faster than foreach { in_array() } when there are many options
374+
$attributeValues = array_flip($attributeValues);
375+
376+
foreach ($options as $option) {
377+
if (isset($attributeValues[$option['value']])) {
378+
$attributeLabels[] = $option['label'];
379+
}
380+
}
375381

376382
return $attributeLabels;
377383
}

0 commit comments

Comments
 (0)