Skip to content

Commit 3e44f8c

Browse files
committed
MAGETWO-96908: [2.3] Wrong attribute value in flat table
1 parent cf69967 commit 3e44f8c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,20 @@ protected function _updateTemporaryTableByStoreValues(
346346
}
347347

348348
//Update not simple attributes (eg. dropdown)
349-
if (isset($flatColumns[$attributeCode . $valueFieldSuffix])) {
350-
$select = $this->_connection->select()->joinInner(
351-
['t' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
352-
't.option_id = et.' . $attributeCode . ' AND t.store_id=' . $storeId,
353-
[$attributeCode . $valueFieldSuffix => 't.value']
354-
);
349+
$columnName = $attributeCode . $valueFieldSuffix;
350+
if (isset($flatColumns[$columnName])) {
351+
$select = $this->_connection->select();
352+
$select->joinLeft(
353+
['t0' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
354+
't0.option_id = et.' . $attributeCode . ' AND t0.store_id = 0',
355+
[]
356+
)->joinLeft(
357+
['ts' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
358+
'ts.option_id = et.' . $attributeCode . ' AND ts.store_id = ' . $storeId,
359+
[]
360+
)->columns(
361+
[$columnName => $this->_connection->getIfNullSql('ts.value', 't0.value')]
362+
)->where($columnName . ' IS NOT NULL');
355363
if (!empty($changedIds)) {
356364
$select->where($this->_connection->quoteInto('et.entity_id IN (?)', $changedIds));
357365
}

0 commit comments

Comments
 (0)