Skip to content

Commit c8b1bae

Browse files
authored
ENGCOM-4860: Fix MySQL syntax error on indexation with certain attribute codes #22559
2 parents 8c53755 + f20d868 commit c8b1bae

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/**
1313
* Class FlatTableBuilder
14+
*
1415
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1516
*/
1617
class FlatTableBuilder
@@ -354,6 +355,7 @@ protected function _updateTemporaryTableByStoreValues(
354355
//Update not simple attributes (eg. dropdown)
355356
$columnName = $attributeCode . $valueFieldSuffix;
356357
if (isset($flatColumns[$columnName])) {
358+
$columnValue = $this->_connection->getIfNullSql('ts.value', 't0.value');
357359
$select = $this->_connection->select();
358360
$select->joinLeft(
359361
['t0' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
@@ -364,8 +366,8 @@ protected function _updateTemporaryTableByStoreValues(
364366
'ts.option_id = et.' . $attributeCode . ' AND ts.store_id = ' . $storeId,
365367
[]
366368
)->columns(
367-
[$columnName => $this->_connection->getIfNullSql('ts.value', 't0.value')]
368-
)->where($attributeCode . ' IS NOT NULL');
369+
[$columnName => $columnValue]
370+
)->where($columnValue . ' IS NOT NULL');
369371
if (!empty($changedIds)) {
370372
$select->where($this->_connection->quoteInto('et.entity_id IN (?)', $changedIds));
371373
}
@@ -389,7 +391,7 @@ protected function _getTemporaryTableName($tableName)
389391
}
390392

391393
/**
392-
* Get MetadataPool
394+
* Get metadata pool
393395
*
394396
* @return \Magento\Framework\EntityManager\MetadataPool
395397
*/

0 commit comments

Comments
 (0)