Skip to content

Commit 0181689

Browse files
sankalpshekharNazar65
authored andcommitted
Simplify if else catalog search full text data provider
1 parent 7120c6e commit 0181689

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,10 @@ public function prepareProductIndex($indexData, $productData, $storeId)
573573
foreach ($attributeData as $attributeId => $attributeValues) {
574574
$value = $this->getAttributeValue($attributeId, $attributeValues, $storeId);
575575
if (!empty($value)) {
576-
if (isset($index[$attributeId])) {
577-
$index[$attributeId][$entityId] = $value;
578-
} else {
579-
$index[$attributeId] = [$entityId => $value];
576+
if (!isset($index[$attributeId])) {
577+
$index[$attributeId] = [];
580578
}
579+
$index[$attributeId][$entityId] = $value;
581580
}
582581
}
583582
}
@@ -645,9 +644,12 @@ private function getAttributeOptionValue($attributeId, $valueIds, $storeId)
645644
$attribute->setStoreId($storeId);
646645
$options = $attribute->getSource()->toOptionArray();
647646
$this->attributeOptions[$optionKey] = array_column($options, 'label', 'value');
648-
$this->attributeOptions[$optionKey] = array_map(function ($value) {
649-
return $this->filterAttributeValue($value);
650-
}, $this->attributeOptions[$optionKey]);
647+
$this->attributeOptions[$optionKey] = array_map(
648+
function ($value) {
649+
return $this->filterAttributeValue($value);
650+
},
651+
$this->attributeOptions[$optionKey]
652+
);
651653
} else {
652654
$this->attributeOptions[$optionKey] = null;
653655
}

0 commit comments

Comments
 (0)