@@ -390,6 +390,7 @@ protected function saveAndReplaceAdvancedPrices()
390
390
$ listSku = [];
391
391
$ tierPrices = [];
392
392
while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
393
+ $ bunchTierPrices = [];
393
394
foreach ($ bunch as $ rowNum => $ rowData ) {
394
395
if (!$ this ->validateRow ($ rowData , $ rowNum )) {
395
396
$ this ->addRowError (ValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
@@ -403,7 +404,7 @@ protected function saveAndReplaceAdvancedPrices()
403
404
$ rowSku = $ rowData [self ::COL_SKU ];
404
405
$ listSku [] = $ rowSku ;
405
406
if (!empty ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])) {
406
- $ tierPrices [ $ rowSku ][] = [
407
+ $ tierPrice = [
407
408
'all_groups ' => $ rowData [self ::COL_TIER_PRICE_CUSTOMER_GROUP ] == self ::VALUE_ALL_GROUPS ,
408
409
'customer_group_id ' => $ this ->getCustomerGroupId (
409
410
$ rowData [self ::COL_TIER_PRICE_CUSTOMER_GROUP ]
@@ -415,17 +416,26 @@ protected function saveAndReplaceAdvancedPrices()
415
416
? $ rowData [self ::COL_TIER_PRICE ] : null ,
416
417
'website_id ' => $ this ->getWebSiteId ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])
417
418
];
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
+ }
418
425
}
419
426
}
420
427
421
428
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 );
424
431
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 );
429
439
}
430
440
}
431
441
0 commit comments