@@ -402,9 +402,7 @@ public function validateData()
402402 protected function _prepareDataForUpdate (array $ rowData )
403403 {
404404 $ multiSeparator = $ this ->getMultipleValueSeparator ();
405- $ entitiesToCreate = [];
406- $ entitiesToUpdate = [];
407- $ attributesToSave = [];
405+ $ entitiesToCreate = $ entitiesToUpdate = $ attributesToSave = [];
408406
409407 // entity table data
410408 $ now = new \DateTime ();
@@ -439,7 +437,11 @@ protected function _prepareDataForUpdate(array $rowData)
439437 }
440438 } elseif ('multiselect ' == $ attributeParameters ['type ' ]) {
441439 $ ids = [];
442- $ values = $ value !== null ? explode ($ multiSeparator , mb_strtolower ($ value )) : [];
440+ if (!is_array ($ value )) {
441+ $ values = $ value !== null ? explode ($ multiSeparator , mb_strtolower ($ value )) : [];
442+ } else {
443+ $ values = array_map ('mb_strtolower ' , $ value );
444+ }
443445 foreach ($ values as $ subValue ) {
444446 $ ids [] = $ this ->getSelectAttrIdByValue ($ attributeParameters , $ subValue );
445447 }
@@ -615,27 +617,32 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
615617 $ isFieldRequired = $ attributeParams ['is_required ' ];
616618 $ isFieldNotSetAndCustomerDoesNotExist =
617619 !isset ($ rowData [$ attributeCode ]) && !$ this ->_getCustomerId ($ email , $ website );
618- $ isFieldSetAndTrimmedValueIsEmpty
619- = isset ($ rowData [$ attributeCode ]) && '' === trim ((string )$ rowData [$ attributeCode ]);
620+ $ isFieldSetAndTrimmedValueIsEmpty = true ;
621+ $ isFieldValueNotEmpty = false ;
622+
623+ if (isset ($ rowData [$ attributeCode ])) {
624+ if (is_array ($ rowData [$ attributeCode ])) {
625+ $ isFieldSetAndTrimmedValueIsEmpty = empty (array_filter ($ rowData [$ attributeCode ], 'trim ' ));
626+ $ isFieldValueNotEmpty = count (array_filter ($ rowData [$ attributeCode ], 'strlen ' )) > 0 ;
627+ } else {
628+ $ isFieldSetAndTrimmedValueIsEmpty = '' === trim ((string )$ rowData [$ attributeCode ]);
629+ $ isFieldValueNotEmpty = strlen ($ rowData [$ attributeCode ]) > 0 ;
630+ }
631+ }
620632
621633 if ($ isFieldRequired && ($ isFieldNotSetAndCustomerDoesNotExist || $ isFieldSetAndTrimmedValueIsEmpty )) {
622634 $ this ->addRowError (self ::ERROR_VALUE_IS_REQUIRED , $ rowNumber , $ attributeCode );
623635 continue ;
624636 }
625637
626- if (isset ($ rowData [$ attributeCode ]) && strlen ((string )$ rowData [$ attributeCode ])) {
627- if ($ attributeParams ['type ' ] == 'select ' ) {
628- continue ;
629- }
630-
638+ if (isset ($ rowData [$ attributeCode ]) && $ isFieldValueNotEmpty && $ attributeParams ['type ' ] != 'select ' ) {
631639 $ this ->isAttributeValid (
632640 $ attributeCode ,
633641 $ attributeParams ,
634642 $ rowData ,
635643 $ rowNumber ,
636- isset ($ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ])
637- ? $ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ]
638- : Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
644+ $ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ]
645+ ?? Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
639646 );
640647 }
641648 }
0 commit comments