@@ -402,9 +402,7 @@ public function validateData()
402
402
protected function _prepareDataForUpdate (array $ rowData )
403
403
{
404
404
$ multiSeparator = $ this ->getMultipleValueSeparator ();
405
- $ entitiesToCreate = [];
406
- $ entitiesToUpdate = [];
407
- $ attributesToSave = [];
405
+ $ entitiesToCreate = $ entitiesToUpdate = $ attributesToSave = [];
408
406
409
407
// entity table data
410
408
$ now = new \DateTime ();
@@ -439,7 +437,11 @@ protected function _prepareDataForUpdate(array $rowData)
439
437
}
440
438
} elseif ('multiselect ' == $ attributeParameters ['type ' ]) {
441
439
$ 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
+ }
443
445
foreach ($ values as $ subValue ) {
444
446
$ ids [] = $ this ->getSelectAttrIdByValue ($ attributeParameters , $ subValue );
445
447
}
@@ -615,27 +617,32 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
615
617
$ isFieldRequired = $ attributeParams ['is_required ' ];
616
618
$ isFieldNotSetAndCustomerDoesNotExist =
617
619
!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
+ }
620
632
621
633
if ($ isFieldRequired && ($ isFieldNotSetAndCustomerDoesNotExist || $ isFieldSetAndTrimmedValueIsEmpty )) {
622
634
$ this ->addRowError (self ::ERROR_VALUE_IS_REQUIRED , $ rowNumber , $ attributeCode );
623
635
continue ;
624
636
}
625
637
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 ' ) {
631
639
$ this ->isAttributeValid (
632
640
$ attributeCode ,
633
641
$ attributeParams ,
634
642
$ rowData ,
635
643
$ 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
639
646
);
640
647
}
641
648
}
0 commit comments