@@ -185,6 +185,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
185
185
* @param AdvancedPricing\Validator\Website $websiteValidator
186
186
* @param AdvancedPricing\Validator\TierPrice $tierPriceValidator
187
187
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
188
+ * @throws \Exception
188
189
*/
189
190
public function __construct (
190
191
\Magento \Framework \Json \Helper \Data $ jsonHelper ,
@@ -255,6 +256,7 @@ public function getEntityTypeCode()
255
256
* @param array $rowData
256
257
* @param int $rowNum
257
258
* @return bool
259
+ * @throws \Zend_Validate_Exception
258
260
*/
259
261
public function validateRow (array $ rowData , $ rowNum )
260
262
{
@@ -308,6 +310,7 @@ protected function _importData()
308
310
* Save advanced pricing
309
311
*
310
312
* @return $this
313
+ * @throws \Exception
311
314
*/
312
315
public function saveAdvancedPricing ()
313
316
{
@@ -319,6 +322,7 @@ public function saveAdvancedPricing()
319
322
* Deletes Advanced price data from raw data.
320
323
*
321
324
* @return $this
325
+ * @throws \Exception
322
326
*/
323
327
public function deleteAdvancedPricing ()
324
328
{
@@ -347,6 +351,7 @@ public function deleteAdvancedPricing()
347
351
* Replace advanced pricing
348
352
*
349
353
* @return $this
354
+ * @throws \Exception
350
355
*/
351
356
public function replaceAdvancedPricing ()
352
357
{
@@ -360,6 +365,7 @@ public function replaceAdvancedPricing()
360
365
* @return $this
361
366
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
362
367
* @SuppressWarnings(PHPMD.NPathComplexity)
368
+ * @throws \Exception
363
369
*/
364
370
protected function saveAndReplaceAdvancedPrices ()
365
371
{
@@ -368,8 +374,8 @@ protected function saveAndReplaceAdvancedPrices()
368
374
$ this ->_cachedSkuToDelete = null ;
369
375
}
370
376
$ listSku = [];
377
+ $ tierPrices = [];
371
378
while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
372
- $ tierPrices = [];
373
379
foreach ($ bunch as $ rowNum => $ rowData ) {
374
380
if (!$ this ->validateRow ($ rowData , $ rowNum )) {
375
381
$ this ->addRowError (ValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
@@ -397,15 +403,8 @@ protected function saveAndReplaceAdvancedPrices()
397
403
];
398
404
}
399
405
}
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 ) {
406
+
407
+ if (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
409
408
$ this ->processCountExistingPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
410
409
->processCountNewPrices ($ tierPrices );
411
410
@@ -415,6 +414,17 @@ protected function saveAndReplaceAdvancedPrices()
415
414
}
416
415
}
417
416
}
417
+
418
+ if (\Magento \ImportExport \Model \Import::BEHAVIOR_REPLACE == $ behavior ) {
419
+ if ($ listSku ) {
420
+ $ this ->processCountNewPrices ($ tierPrices );
421
+ if ($ this ->deleteProductTierPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE )) {
422
+ $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE );
423
+ $ this ->setUpdatedAt ($ listSku );
424
+ }
425
+ }
426
+ }
427
+
418
428
return $ this ;
419
429
}
420
430
@@ -424,6 +434,7 @@ protected function saveAndReplaceAdvancedPrices()
424
434
* @param array $priceData
425
435
* @param string $table
426
436
* @return $this
437
+ * @throws \Exception
427
438
*/
428
439
protected function saveProductPrices (array $ priceData , $ table )
429
440
{
@@ -455,6 +466,7 @@ protected function saveProductPrices(array $priceData, $table)
455
466
* @param array $listSku
456
467
* @param string $table
457
468
* @return boolean
469
+ * @throws \Exception
458
470
*/
459
471
protected function deleteProductTierPrices (array $ listSku , $ table )
460
472
{
@@ -532,6 +544,7 @@ protected function getCustomerGroupId($customerGroup)
532
544
* Retrieve product skus
533
545
*
534
546
* @return array
547
+ * @throws \Exception
535
548
*/
536
549
protected function retrieveOldSkus ()
537
550
{
@@ -552,6 +565,7 @@ protected function retrieveOldSkus()
552
565
* @param array $prices
553
566
* @param string $table
554
567
* @return $this
568
+ * @throws \Exception
555
569
*/
556
570
protected function processCountExistingPrices ($ prices , $ table )
557
571
{
0 commit comments