@@ -379,11 +379,11 @@ public function getInvalidAttribute()
379
379
}
380
380
381
381
/**
382
- * Is valid attributes
382
+ * Validate attributes against configured properties
383
383
*
384
384
* @return array
385
385
*/
386
- protected function isValidAttributes ()
386
+ private function validateAttributes (): array
387
387
{
388
388
$ this ->_clearMessages ();
389
389
$ this ->setInvalidAttribute (null );
@@ -412,21 +412,52 @@ protected function isValidAttributes()
412
412
return $ attributeValidationResult ;
413
413
}
414
414
415
+ /**
416
+ * Is valid attributes
417
+ *
418
+ * @return bool
419
+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
420
+ */
421
+ protected function isValidAttributes ()
422
+ {
423
+ $ this ->_clearMessages ();
424
+ $ this ->setInvalidAttribute (null );
425
+ if (!isset ($ this ->_rowData ['product_type ' ])) {
426
+ return false ;
427
+ }
428
+ $ entityTypeModel = $ this ->context ->retrieveProductTypeByName ($ this ->_rowData ['product_type ' ]);
429
+ if ($ entityTypeModel ) {
430
+ foreach ($ this ->_rowData as $ attrCode => $ attrValue ) {
431
+ $ attrParams = $ entityTypeModel ->retrieveAttributeFromCache ($ attrCode );
432
+ if ($ attrCode === Product::COL_CATEGORY && $ attrValue ) {
433
+ $ this ->isCategoriesValid ($ attrValue );
434
+ } elseif ($ attrParams ) {
435
+ $ this ->isAttributeValid ($ attrCode , $ attrParams , $ this ->_rowData );
436
+ }
437
+ }
438
+ if ($ this ->getMessages ()) {
439
+ return false ;
440
+ }
441
+ }
442
+ return true ;
443
+ }
444
+
415
445
/**
416
446
* @inheritdoc
417
447
*/
418
448
public function isValid ($ value )
419
449
{
420
450
$ this ->_rowData = $ value ;
421
451
$ this ->_clearMessages ();
422
- $ validatedAttributes = $ this ->isValidAttributes ();
452
+ $ validatedAttributes = $ this ->validateAttributes ();
423
453
/** @var Product\Validator\AbstractImportValidator $validator */
424
454
foreach ($ this ->validators as $ validator ) {
425
455
if (!$ validator ->isValid ($ value )) {
426
456
$ this ->_addMessages ($ validator ->getMessages ());
427
457
} else {
428
458
//prioritize specialized validation
429
459
if ($ validator ->getFieldName () &&
460
+ isset ($ validatedAttributes ['attributes ' ]) &&
430
461
$ validatedAttributes ['attributes ' ][$ validator ->getFieldName ()] === false
431
462
) {
432
463
$ validatedAttributes ['attributes ' ][$ validator ->getFieldName ()] = true ;
0 commit comments