Skip to content

Commit e60bc4b

Browse files
committed
AC-1214:Price mismatch in frontend product search and product details pages - Set global value if attribute scope is global
1 parent 2301b04 commit e60bc4b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function execute($entityType, $entityData, $arguments = [])
146146
$attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId();
147147
$attributesMap[$attribute->getAttributeId()] = $attribute->getAttributeCode();
148148
$attributeScopeGlobal[$attribute->getAttributeId()] =
149-
$attribute->getIsGlobal() === ScopedAttributeInterface::SCOPE_GLOBAL;
149+
$attribute->getIsGlobal() === ScopedAttributeInterface::SCOPE_GLOBAL ? 1 : 0;
150150
}
151151
}
152152
if (count($attributeTables)) {
@@ -180,13 +180,23 @@ public function execute($entityType, $entityData, $arguments = [])
180180
$attributes = $connection->fetchAll($orderedUnionSelect);
181181
foreach ($attributes as $attributeValue) {
182182
if (isset($attributesMap[$attributeValue['attribute_id']])) {
183-
if ($attributeScopeGlobal[$attributeValue['attribute_id']] &&
184-
(int)$attributeValue['store_id'] !== Store::DEFAULT_STORE_ID
185-
) {
183+
$isGlobalAttribute = $attributeScopeGlobal[$attributeValue['attribute_id']];
184+
$storeId = $attributeValue['store_id'] ?? null;
185+
186+
// Set global value if attribute scope is set to Global
187+
if ($isGlobalAttribute && (int)$storeId === Store::DEFAULT_STORE_ID) {
188+
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
189+
continue;
190+
}
191+
192+
if (!$isGlobalAttribute && (int)$storeId === Store::DEFAULT_STORE_ID) {
186193
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
187194
continue;
188195
}
189-
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
196+
197+
if (!$isGlobalAttribute && (int)$storeId !== Store::DEFAULT_STORE_ID) {
198+
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
199+
}
190200
} else {
191201
$this->logger->warning(
192202
"Attempt to load value of nonexistent EAV attribute",

0 commit comments

Comments
 (0)