@@ -379,11 +379,11 @@ public function getInvalidAttribute()
379379 }
380380
381381 /**
382- * Is valid attributes
382+ * Validate attributes against configured properties
383383 *
384384 * @return array
385385 */
386- protected function isValidAttributes ()
386+ private function validateAttributes (): array
387387 {
388388 $ this ->_clearMessages ();
389389 $ this ->setInvalidAttribute (null );
@@ -412,21 +412,52 @@ protected function isValidAttributes()
412412 return $ attributeValidationResult ;
413413 }
414414
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+
415445 /**
416446 * @inheritdoc
417447 */
418448 public function isValid ($ value )
419449 {
420450 $ this ->_rowData = $ value ;
421451 $ this ->_clearMessages ();
422- $ validatedAttributes = $ this ->isValidAttributes ();
452+ $ validatedAttributes = $ this ->validateAttributes ();
423453 /** @var Product\Validator\AbstractImportValidator $validator */
424454 foreach ($ this ->validators as $ validator ) {
425455 if (!$ validator ->isValid ($ value )) {
426456 $ this ->_addMessages ($ validator ->getMessages ());
427457 } else {
428458 //prioritize specialized validation
429459 if ($ validator ->getFieldName () &&
460+ isset ($ validatedAttributes ['attributes ' ]) &&
430461 $ validatedAttributes ['attributes ' ][$ validator ->getFieldName ()] === false
431462 ) {
432463 $ validatedAttributes ['attributes ' ][$ validator ->getFieldName ()] = true ;
0 commit comments