5
5
*/
6
6
namespace Magento \CustomerImportExport \Model \Import ;
7
7
8
+ use Magento \ImportExport \Model \Import ;
8
9
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
9
10
10
11
/**
@@ -491,15 +492,13 @@ protected function _prepareDataForUpdate(array $rowData)
491
492
{
492
493
$ email = strtolower ($ rowData [self ::COLUMN_EMAIL ]);
493
494
$ customerId = $ this ->_getCustomerId ($ email , $ rowData [self ::COLUMN_WEBSITE ]);
494
-
495
495
// entity table data
496
496
$ entityRowNew = [];
497
497
$ entityRowUpdate = [];
498
498
// attribute values
499
499
$ attributes = [];
500
500
// customer default addresses
501
501
$ defaults = [];
502
-
503
502
$ newAddress = true ;
504
503
// get address id
505
504
if (isset (
@@ -519,7 +518,6 @@ protected function _prepareDataForUpdate(array $rowData)
519
518
'parent_id ' => $ customerId ,
520
519
'updated_at ' => (new \DateTime ())->format (\Magento \Framework \Stdlib \DateTime::DATETIME_PHP_FORMAT ),
521
520
];
522
-
523
521
foreach ($ this ->_attributes as $ attributeAlias => $ attributeParams ) {
524
522
if (array_key_exists ($ attributeAlias , $ rowData )) {
525
523
if (!strlen ($ rowData [$ attributeAlias ])) {
@@ -534,6 +532,15 @@ protected function _prepareDataForUpdate(array $rowData)
534
532
} elseif ('datetime ' == $ attributeParams ['type ' ]) {
535
533
$ value = (new \DateTime ())->setTimestamp (strtotime ($ rowData [$ attributeAlias ]));
536
534
$ value = $ value ->format (\Magento \Framework \Stdlib \DateTime::DATETIME_PHP_FORMAT );
535
+ } elseif ('multiselect ' == $ attributeParams ['type ' ]) {
536
+ $ separator = isset ($ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ]) ?
537
+ $ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ] :
538
+ Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR ;
539
+ $ value = str_replace (
540
+ $ separator ,
541
+ Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR ,
542
+ $ rowData [$ attributeAlias ]
543
+ );
537
544
} else {
538
545
$ value = $ rowData [$ attributeAlias ];
539
546
}
@@ -544,15 +551,13 @@ protected function _prepareDataForUpdate(array $rowData)
544
551
}
545
552
}
546
553
}
547
-
548
554
foreach (self ::getDefaultAddressAttributeMapping () as $ columnName => $ attributeCode ) {
549
555
if (!empty ($ rowData [$ columnName ])) {
550
556
/** @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
551
557
$ table = $ this ->_getCustomerEntity ()->getResource ()->getTable ('customer_entity ' );
552
558
$ defaults [$ table ][$ customerId ][$ attributeCode ] = $ addressId ;
553
559
}
554
560
}
555
-
556
561
// let's try to find region ID
557
562
$ entityRow ['region_id ' ] = null ;
558
563
if (!empty ($ rowData [self ::COLUMN_REGION ])) {
@@ -565,7 +570,6 @@ protected function _prepareDataForUpdate(array $rowData)
565
570
$ entityRow ['region_id ' ] = $ regionId ;
566
571
}
567
572
}
568
-
569
573
if ($ newAddress ) {
570
574
$ entityRowNew = $ entityRow ;
571
575
$ entityRowNew ['created_at ' ] =
@@ -740,7 +744,16 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
740
744
continue ;
741
745
}
742
746
if (isset ($ rowData [$ attributeCode ]) && strlen ($ rowData [$ attributeCode ])) {
743
- $ this ->isAttributeValid ($ attributeCode , $ attributeParams , $ rowData , $ rowNumber );
747
+ $ multiSeparator = isset ($ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ]) ?
748
+ $ this ->_parameters [Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR ] :
749
+ Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR ;
750
+ $ this ->isAttributeValid (
751
+ $ attributeCode ,
752
+ $ attributeParams ,
753
+ $ rowData ,
754
+ $ rowNumber ,
755
+ $ multiSeparator
756
+ );
744
757
} elseif ($ attributeParams ['is_required ' ] && (!isset (
745
758
$ this ->_addresses [$ customerId ]
746
759
) || !in_array (
0 commit comments