@@ -344,11 +344,23 @@ protected function _loadSkuSuperAttributeValues($bunch, $newSku, $oldSku)
344
344
/**
345
345
* Array of SKU to array of super attribute values for all products.
346
346
*
347
+ * @param array $bunch
347
348
* @return $this
348
349
*/
349
- protected function _loadSkuSuperData ( )
350
+ protected function _loadSkuSuperDataForBunch ( array $ bunch )
350
351
{
351
- if (!$ this ->_skuSuperData ) {
352
+ $ newSku = $ this ->_entityModel ->getNewSku ();
353
+ $ oldSku = $ this ->_entityModel ->getOldSku ();
354
+ $ productIds = [];
355
+ foreach ($ bunch as $ rowData ) {
356
+ $ sku = $ rowData [ImportProduct::COL_SKU ];
357
+ $ productData = isset ($ newSku [$ sku ]) ? $ newSku [$ sku ] : $ oldSku [$ sku ];
358
+ $ productIds [] = $ productData ['entity_id ' ];
359
+ }
360
+
361
+ $ this ->_productSuperAttrs = [];
362
+ $ this ->_skuSuperData = [];
363
+ if (!empty ($ productIds )) {
352
364
$ mainTable = $ this ->_resource ->getTableName ('catalog_product_super_attribute ' );
353
365
$ optionTable = $ this ->_resource ->getTableName ('eav_attribute_option ' );
354
366
$ select = $ this ->_connection ->select ()->from (
@@ -362,6 +374,9 @@ protected function _loadSkuSuperData()
362
374
'o.attribute_id '
363
375
),
364
376
['option_id ' ]
377
+ )->where (
378
+ 'product_id IN ( ? ) ' ,
379
+ $ productIds
365
380
);
366
381
367
382
foreach ($ this ->_connection ->fetchAll ($ select ) as $ row ) {
@@ -696,11 +711,10 @@ public function saveData()
696
711
$ this ->_productSuperData = [];
697
712
$ this ->_productData = null ;
698
713
699
- if ($ this ->_entityModel ->getBehavior () == \Magento \ImportExport \Model \Import::BEHAVIOR_APPEND ) {
700
- $ this ->_loadSkuSuperData ();
701
- }
702
-
703
714
while ($ bunch = $ this ->_entityModel ->getNextBunch ()) {
715
+ if ($ this ->_entityModel ->getBehavior () == \Magento \ImportExport \Model \Import::BEHAVIOR_APPEND ) {
716
+ $ this ->_loadSkuSuperDataForBunch ($ bunch );
717
+ }
704
718
if (!$ this ->configurableInBunch ($ bunch )) {
705
719
continue ;
706
720
}
0 commit comments