Skip to content

Commit e26f379

Browse files
authored
ENGCOM-5160: [Backport] #21747 Fix catalog_product_flat_data attribute value for store during indexer #22581
2 parents 4885d16 + 459f032 commit e26f379

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,16 @@ protected function _fillTemporaryTable(
289289

290290
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
291291
foreach ($columnsList as $columnName => $attribute) {
292-
$countTableName = 't' . $iterationNum++;
292+
$countTableName = 't' . ($iterationNum++);
293293
$joinCondition = sprintf(
294-
'e.%3$s = %1$s.%3$s AND %1$s.attribute_id = %2$d AND %1$s.store_id = 0',
294+
'e.%3$s = %1$s.%3$s' .
295+
' AND %1$s.attribute_id = %2$d' .
296+
' AND (%1$s.store_id = %4$d' .
297+
' OR %1$s.store_id = 0)',
295298
$countTableName,
296299
$attribute->getId(),
297-
$metadata->getLinkField()
300+
$metadata->getLinkField(),
301+
$storeId
298302
);
299303

300304
$select->joinLeft(
@@ -308,9 +312,10 @@ protected function _fillTemporaryTable(
308312
$columnValueName = $attributeCode . $valueFieldSuffix;
309313
if (isset($flatColumns[$columnValueName])) {
310314
$valueJoinCondition = sprintf(
311-
'e.%1$s = %2$s.option_id AND %2$s.store_id = 0',
315+
'e.%1$s = %2$s.option_id AND (%2$s.store_id = %3$d OR %2$s.store_id = 0)',
312316
$attributeCode,
313-
$countTableName
317+
$countTableName,
318+
$storeId
314319
);
315320
$selectValue->joinLeft(
316321
[

0 commit comments

Comments
 (0)