@@ -2432,6 +2432,7 @@ public function getRowScope(array $rowData)
2432
2432
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
2433
2433
* @SuppressWarnings(PHPMD.NPathComplexity)
2434
2434
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
2435
+ * @throws \Zend_Validate_Exception
2435
2436
*/
2436
2437
public function validateRow (array $ rowData , $ rowNum )
2437
2438
{
@@ -2459,25 +2460,23 @@ public function validateRow(array $rowData, $rowNum)
2459
2460
return true ;
2460
2461
}
2461
2462
2463
+ // if product doesn't exist, need to throw critical error else all errors should be not critical.
2464
+ $ errorLevel = $ this ->getValidationErrorLevel ();
2465
+
2462
2466
if (!$ this ->validator ->isValid ($ rowData )) {
2463
2467
foreach ($ this ->validator ->getMessages () as $ message ) {
2464
- $ this ->skipRow (
2465
- $ rowNum ,
2466
- $ message ,
2467
- ProcessingError::ERROR_LEVEL_NOT_CRITICAL ,
2468
- $ this ->validator ->getInvalidAttribute ()
2469
- );
2468
+ $ this ->skipRow ($ rowNum , $ message , $ errorLevel , $ this ->validator ->getInvalidAttribute ());
2470
2469
}
2471
2470
}
2472
2471
2473
2472
if (null === $ sku ) {
2474
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_SKU_IS_EMPTY );
2473
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_SKU_IS_EMPTY , $ errorLevel );
2475
2474
} elseif (false === $ sku ) {
2476
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_ROW_IS_ORPHAN );
2475
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_ROW_IS_ORPHAN , $ errorLevel );
2477
2476
} elseif (self ::SCOPE_STORE == $ rowScope
2478
2477
&& !$ this ->storeResolver ->getStoreCodeToId ($ rowData [self ::COL_STORE ])
2479
2478
) {
2480
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_STORE );
2479
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_STORE , $ errorLevel );
2481
2480
}
2482
2481
2483
2482
// SKU is specified, row is SCOPE_DEFAULT, new product block begins
@@ -2492,15 +2491,15 @@ public function validateRow(array $rowData, $rowNum)
2492
2491
$ this ->prepareNewSkuData ($ sku )
2493
2492
);
2494
2493
} else {
2495
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_TYPE_UNSUPPORTED );
2494
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_TYPE_UNSUPPORTED , $ errorLevel );
2496
2495
}
2497
2496
} else {
2498
2497
// validate new product type and attribute set
2499
2498
if (!isset ($ rowData [self ::COL_TYPE ], $ this ->_productTypeModels [$ rowData [self ::COL_TYPE ]])) {
2500
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_TYPE );
2499
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_TYPE , $ errorLevel );
2501
2500
} elseif (!isset ($ rowData [self ::COL_ATTR_SET ], $ this ->_attrSetNameToId [$ rowData [self ::COL_ATTR_SET ]])
2502
2501
) {
2503
- $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_ATTR_SET );
2502
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_INVALID_ATTR_SET , $ errorLevel );
2504
2503
} elseif ($ this ->skuProcessor ->getNewSku ($ sku ) === null ) {
2505
2504
$ this ->skuProcessor ->addNewSku (
2506
2505
$ sku ,
@@ -2570,11 +2569,7 @@ public function validateRow(array $rowData, $rowNum)
2570
2569
$ newFromTimestamp = strtotime ($ this ->dateTime ->formatDate ($ rowData [self ::COL_NEW_FROM_DATE ], false ));
2571
2570
$ newToTimestamp = strtotime ($ this ->dateTime ->formatDate ($ rowData [self ::COL_NEW_TO_DATE ], false ));
2572
2571
if ($ newFromTimestamp > $ newToTimestamp ) {
2573
- $ this ->addRowError (
2574
- ValidatorInterface::ERROR_NEW_TO_DATE ,
2575
- $ rowNum ,
2576
- $ rowData [self ::COL_NEW_TO_DATE ]
2577
- );
2572
+ $ this ->skipRow ($ rowNum , ValidatorInterface::ERROR_NEW_TO_DATE , $ errorLevel , $ rowData [self ::COL_NEW_TO_DATE ]);
2578
2573
}
2579
2574
}
2580
2575
@@ -3121,4 +3116,17 @@ private function skipRow(
3121
3116
->addRowToSkip ($ rowNum );
3122
3117
return $ this ;
3123
3118
}
3119
+
3120
+ /**
3121
+ * Returns errorLevel for validation
3122
+ *
3123
+ * @param string $sku
3124
+ * @return string
3125
+ */
3126
+ private function getValidationErrorLevel ($ sku ): string
3127
+ {
3128
+ return (!$ this ->isSkuExist ($ sku ) && Import::BEHAVIOR_REPLACE !== $ this ->getBehavior ())
3129
+ ? ProcessingError::ERROR_LEVEL_CRITICAL
3130
+ : ProcessingError::ERROR_LEVEL_NOT_CRITICAL ;
3131
+ }
3124
3132
}
0 commit comments