diff --git a/vendor/magento/module-advanced-pricing-import-export/Model/Import/AdvancedPricing.php b/vendor/magento/module-advanced-pricing-import-export/Model/Import/AdvancedPricing.php index 30b2535853e3..bbb62341e177 100644 --- a/vendor/magento/module-advanced-pricing-import-export/Model/Import/AdvancedPricing.php +++ b/vendor/magento/module-advanced-pricing-import-export/Model/Import/AdvancedPricing.php @@ -397,6 +397,7 @@ protected function saveAndReplaceAdvancedPrices() $listSku = []; $tierPrices = []; while ($bunch = $this->_dataSourceModel->getNextBunch()) { + $bunchTierPrices = []; foreach ($bunch as $rowNum => $rowData) { if (!$this->validateRow($rowData, $rowNum)) { $this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, $rowNum); @@ -410,7 +411,7 @@ protected function saveAndReplaceAdvancedPrices() $rowSku = $rowData[self::COL_SKU]; $listSku[] = $rowSku; if (!empty($rowData[self::COL_TIER_PRICE_WEBSITE])) { - $tierPrices[$rowSku][] = [ + $tierPrice = [ 'all_groups' => $rowData[self::COL_TIER_PRICE_CUSTOMER_GROUP] == self::VALUE_ALL_GROUPS, 'customer_group_id' => $this->getCustomerGroupId( $rowData[self::COL_TIER_PRICE_CUSTOMER_GROUP] @@ -422,17 +423,26 @@ protected function saveAndReplaceAdvancedPrices() ? $rowData[self::COL_TIER_PRICE] : null, 'website_id' => $this->getWebSiteId($rowData[self::COL_TIER_PRICE_WEBSITE]) ]; + if (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) { + $bunchTierPrices[$rowSku][] = $tierPrice; + } + if (\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE == $behavior) { + $tierPrices[$rowSku][] = $tierPrice; + } } } if (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) { - $this->processCountExistingPrices($tierPrices, self::TABLE_TIER_PRICE) - ->processCountNewPrices($tierPrices); + $this->processCountExistingPrices($bunchTierPrices, self::TABLE_TIER_PRICE) + ->processCountNewPrices($bunchTierPrices); - $this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE); - if ($listSku) { - $this->setUpdatedAt($listSku); - } + $this->saveProductPrices($bunchTierPrices, self::TABLE_TIER_PRICE); + } + } + + if (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) { + if ($listSku) { + $this->setUpdatedAt($listSku); } }