@@ -390,6 +390,7 @@ protected function saveAndReplaceAdvancedPrices()
390390 $ listSku = [];
391391 $ tierPrices = [];
392392 while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
393+ $ bunchTierPrices = [];
393394 foreach ($ bunch as $ rowNum => $ rowData ) {
394395 if (!$ this ->validateRow ($ rowData , $ rowNum )) {
395396 $ this ->addRowError (ValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
@@ -403,7 +404,7 @@ protected function saveAndReplaceAdvancedPrices()
403404 $ rowSku = $ rowData [self ::COL_SKU ];
404405 $ listSku [] = $ rowSku ;
405406 if (!empty ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])) {
406- $ tierPrices [ $ rowSku ][] = [
407+ $ tierPrice = [
407408 'all_groups ' => $ rowData [self ::COL_TIER_PRICE_CUSTOMER_GROUP ] == self ::VALUE_ALL_GROUPS ,
408409 'customer_group_id ' => $ this ->getCustomerGroupId (
409410 $ rowData [self ::COL_TIER_PRICE_CUSTOMER_GROUP ]
@@ -415,17 +416,26 @@ protected function saveAndReplaceAdvancedPrices()
415416 ? $ rowData [self ::COL_TIER_PRICE ] : null ,
416417 'website_id ' => $ this ->getWebSiteId ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])
417418 ];
419+ if (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
420+ $ bunchTierPrices [$ rowSku ][] = $ tierPrice ;
421+ }
422+ if (\Magento \ImportExport \Model \Import::BEHAVIOR_REPLACE == $ behavior ) {
423+ $ tierPrices [$ rowSku ][] = $ tierPrice ;
424+ }
418425 }
419426 }
420427
421428 if (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
422- $ this ->processCountExistingPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
423- ->processCountNewPrices ($ tierPrices );
429+ $ this ->processCountExistingPrices ($ bunchTierPrices , self ::TABLE_TIER_PRICE )
430+ ->processCountNewPrices ($ bunchTierPrices );
424431
425- $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE );
426- if ($ listSku ) {
427- $ this ->setUpdatedAt ($ listSku );
428- }
432+ $ this ->saveProductPrices ($ bunchTierPrices , self ::TABLE_TIER_PRICE );
433+ }
434+ }
435+
436+ if (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
437+ if ($ listSku ) {
438+ $ this ->setUpdatedAt ($ listSku );
429439 }
430440 }
431441
0 commit comments