10
10
use Magento \Framework \EntityManager \MetadataPool ;
11
11
12
12
/**
13
- * Class FlatTableBuilder
13
+ * Class for building flat index
14
+ *
14
15
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15
16
*/
16
17
class FlatTableBuilder
@@ -346,12 +347,21 @@ protected function _updateTemporaryTableByStoreValues(
346
347
}
347
348
348
349
//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
- );
350
+ $ columnName = $ attributeCode . $ valueFieldSuffix ;
351
+ if (isset ($ flatColumns [$ columnName ])) {
352
+ $ columnValue = $ this ->_connection ->getIfNullSql ('ts.value ' , 't0.value ' );
353
+ $ select = $ this ->_connection ->select ();
354
+ $ select ->joinLeft (
355
+ ['t0 ' => $ this ->_productIndexerHelper ->getTable ('eav_attribute_option_value ' )],
356
+ 't0.option_id = et. ' . $ attributeCode . ' AND t0.store_id = 0 ' ,
357
+ []
358
+ )->joinLeft (
359
+ ['ts ' => $ this ->_productIndexerHelper ->getTable ('eav_attribute_option_value ' )],
360
+ 'ts.option_id = et. ' . $ attributeCode . ' AND ts.store_id = ' . $ storeId ,
361
+ []
362
+ )->columns (
363
+ [$ columnName => $ columnValue ]
364
+ )->where ($ columnValue . ' IS NOT NULL ' );
355
365
if (!empty ($ changedIds )) {
356
366
$ select ->where ($ this ->_connection ->quoteInto ('et.entity_id IN (?) ' , $ changedIds ));
357
367
}
@@ -374,6 +384,8 @@ protected function _getTemporaryTableName($tableName)
374
384
}
375
385
376
386
/**
387
+ * Get metadata pool
388
+ *
377
389
* @return \Magento\Framework\EntityManager\MetadataPool
378
390
*/
379
391
private function getMetadataPool ()
0 commit comments