@@ -286,7 +286,11 @@ public function getProductAttributes($storeId, array $productIds, array $attribu
286
286
{
287
287
$ result = [];
288
288
$ selects = [];
289
- $ ifStoreValue = $ this ->connection ->getCheckSql ('t_store.value_id > 0 ' , 't_store.value ' , 't_default.value ' );
289
+ $ ifStoreValue = $ this ->connection ->getCheckSql (
290
+ 'cpe_type.value_id > 0 ' ,
291
+ 'cpe_type.value ' ,
292
+ 'cpe_type_default.value '
293
+ );
290
294
$ linkField = $ this ->metadata ->getLinkField ();
291
295
$ productLinkFieldsToEntityIdMap = $ this ->connection ->fetchPairs (
292
296
$ this ->connection ->select ()->from (
@@ -300,28 +304,43 @@ public function getProductAttributes($storeId, array $productIds, array $attribu
300
304
foreach ($ attributeTypes as $ backendType => $ attributeIds ) {
301
305
if ($ attributeIds ) {
302
306
$ tableName = $ this ->getTable ('catalog_product_entity_ ' . $ backendType );
303
- $ selects [] = $ this ->connection ->select ()->from (
304
- ['t_default ' => $ tableName ],
305
- [$ linkField , 'attribute_id ' ]
306
- )->joinLeft (
307
- ['t_store ' => $ tableName ],
308
- $ this ->connection ->quoteInto (
309
- 't_default. ' . $ linkField . '=t_store. ' . $ linkField .
310
- ' AND t_default.attribute_id=t_store.attribute_id ' .
311
- ' AND t_store.store_id = ? ' ,
312
- $ storeId
313
- ),
314
- ['value ' => $ this ->unifyField ($ ifStoreValue , $ backendType )]
315
- )->where (
316
- 't_default.store_id = ? ' ,
317
- 0
318
- )->where (
319
- 't_default.attribute_id IN (?) ' ,
320
- $ attributeIds
321
- )->where (
322
- 't_default. ' . $ linkField . ' IN (?) ' ,
323
- array_keys ($ productLinkFieldsToEntityIdMap )
324
- );
307
+ $ selects [] = $ this ->connection ->select ()
308
+ ->from (
309
+ ['cpe ' => $ this ->getTable ('catalog_product_entity ' )],
310
+ []
311
+ )->joinInner (
312
+ ['cea ' => $ this ->getTable ('catalog_eav_attribute ' )],
313
+ '' ,
314
+ []
315
+ )->joinLeft (
316
+ ['cpe_type ' => $ tableName ],
317
+ $ this ->connection ->quoteInto (
318
+ 'cpe. ' . $ linkField . ' = cpe_type. ' . $ linkField . ' AND cpe_type.store_id = ? '
319
+ . 'AND cea.attribute_id = cpe_type.attribute_id ' ,
320
+ $ storeId
321
+ ),
322
+ []
323
+ )->joinLeft (
324
+ ['cpe_type_default ' => $ tableName ],
325
+ 'cpe. ' . $ linkField . ' = cpe_type_default. ' . $ linkField
326
+ . ' AND cpe_type_default.store_id = 0 '
327
+ . ' AND cea.attribute_id = cpe_type_default.attribute_id ' ,
328
+ []
329
+ )->where (
330
+ 'cea.attribute_id IN (?) ' ,
331
+ $ attributeIds
332
+ )->where (
333
+ 'cpe. ' . $ linkField . ' IN (?) ' ,
334
+ array_keys ($ productLinkFieldsToEntityIdMap )
335
+ )->where (
336
+ 'cpe_type.attribute_id IS NOT NULL OR cpe_type_default.attribute_id IS NOT NULL '
337
+ )->columns (
338
+ [
339
+ $ linkField => 'cpe. ' . $ linkField ,
340
+ 'attribute_id ' => 'cea.attribute_id ' ,
341
+ 'value ' => $ this ->unifyField ($ ifStoreValue , $ backendType )
342
+ ]
343
+ );
325
344
}
326
345
}
327
346
0 commit comments