Skip to content

Commit a572ae2

Browse files
Fixing a bug with replace method in Advanced Prices in CSV Import #18761
1 parent 2f1bc31 commit a572ae2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ protected function saveAndReplaceAdvancedPrices()
368368
$this->_cachedSkuToDelete = null;
369369
}
370370
$listSku = [];
371+
$tierPrices = [];
371372
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
372-
$tierPrices = [];
373373
foreach ($bunch as $rowNum => $rowData) {
374374
if (!$this->validateRow($rowData, $rowNum)) {
375375
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, $rowNum);
@@ -397,15 +397,8 @@ protected function saveAndReplaceAdvancedPrices()
397397
];
398398
}
399399
}
400-
if (\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE == $behavior) {
401-
if ($listSku) {
402-
$this->processCountNewPrices($tierPrices);
403-
if ($this->deleteProductTierPrices(array_unique($listSku), self::TABLE_TIER_PRICE)) {
404-
$this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE);
405-
$this->setUpdatedAt($listSku);
406-
}
407-
}
408-
} elseif (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) {
400+
401+
if (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) {
409402
$this->processCountExistingPrices($tierPrices, self::TABLE_TIER_PRICE)
410403
->processCountNewPrices($tierPrices);
411404
$this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE);
@@ -414,6 +407,17 @@ protected function saveAndReplaceAdvancedPrices()
414407
}
415408
}
416409
}
410+
411+
if (\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE == $behavior) {
412+
if ($listSku) {
413+
$this->processCountNewPrices($tierPrices);
414+
if ($this->deleteProductTierPrices(array_unique($listSku), self::TABLE_TIER_PRICE)) {
415+
$this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE);
416+
$this->setUpdatedAt($listSku);
417+
}
418+
}
419+
}
420+
417421
return $this;
418422
}
419423

0 commit comments

Comments
 (0)