10
10
use Magento \Customer \Api \Data \CustomerInterface ;
11
11
use Magento \Customer \Model \Indexer \Processor ;
12
12
use Magento \Framework \App \ObjectManager ;
13
+ use Magento \Framework \Stdlib \DateTime ;
13
14
use Magento \ImportExport \Model \Import ;
14
15
use Magento \ImportExport \Model \Import \AbstractSource ;
15
16
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
17
+ use Magento \Store \Model \Store ;
16
18
17
19
/**
18
20
* Customer entity import
@@ -407,11 +409,9 @@ protected function _prepareDataForUpdate(array $rowData)
407
409
408
410
// entity table data
409
411
$ now = new \DateTime ();
410
- if (empty ($ rowData ['created_at ' ])) {
411
- $ createdAt = $ now ;
412
- } else {
413
- $ createdAt = (new \DateTime ())->setTimestamp (strtotime ($ rowData ['created_at ' ]));
414
- }
412
+ $ createdAt = empty ($ rowData ['created_at ' ])
413
+ ? $ now
414
+ : (new \DateTime ())->setTimestamp (strtotime ($ rowData ['created_at ' ]));
415
415
$ emailInLowercase = strtolower (trim ($ rowData [self ::COLUMN_EMAIL ]));
416
416
$ newCustomer = false ;
417
417
$ entityId = $ this ->_getCustomerId ($ emailInLowercase , $ rowData [self ::COLUMN_WEBSITE ]);
@@ -448,7 +448,7 @@ protected function _prepareDataForUpdate(array $rowData)
448
448
$ value = implode (', ' , $ ids );
449
449
} elseif ('datetime ' == $ attributeParameters ['type ' ] && !empty ($ value )) {
450
450
$ value = (new \DateTime ())->setTimestamp (strtotime ($ value ));
451
- $ value = $ value ->format (\ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT );
451
+ $ value = $ value ->format (DateTime::DATETIME_PHP_FORMAT );
452
452
}
453
453
if (!$ this ->_attributes [$ attributeCode ]['is_static ' ]) {
454
454
/** @var $attribute \Magento\Customer\Model\Attribute */
@@ -473,16 +473,16 @@ protected function _prepareDataForUpdate(array $rowData)
473
473
// create
474
474
$ entityRow ['group_id ' ] = empty ($ rowData ['group_id ' ]) ? self ::DEFAULT_GROUP_ID : $ rowData ['group_id ' ];
475
475
$ entityRow ['store_id ' ] = empty ($ rowData [self ::COLUMN_STORE ])
476
- ? \ Magento \ Store \ Model \ Store::DEFAULT_STORE_ID : $ this ->_storeCodeToId [$ rowData [self ::COLUMN_STORE ]];
477
- $ entityRow ['created_at ' ] = $ createdAt ->format (\ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT );
478
- $ entityRow ['updated_at ' ] = $ now ->format (\ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT );
476
+ ? Store::DEFAULT_STORE_ID : $ this ->_storeCodeToId [$ rowData [self ::COLUMN_STORE ]];
477
+ $ entityRow ['created_at ' ] = $ createdAt ->format (DateTime::DATETIME_PHP_FORMAT );
478
+ $ entityRow ['updated_at ' ] = $ now ->format (DateTime::DATETIME_PHP_FORMAT );
479
479
$ entityRow ['website_id ' ] = $ this ->_websiteCodeToId [$ rowData [self ::COLUMN_WEBSITE ]];
480
480
$ entityRow ['email ' ] = $ emailInLowercase ;
481
481
$ entityRow ['is_active ' ] = 1 ;
482
482
$ entitiesToCreate [] = $ entityRow ;
483
483
} else {
484
484
// edit
485
- $ entityRow ['updated_at ' ] = $ now ->format (\ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT );
485
+ $ entityRow ['updated_at ' ] = $ now ->format (DateTime::DATETIME_PHP_FORMAT );
486
486
if (!empty ($ rowData [self ::COLUMN_STORE ])) {
487
487
$ entityRow ['store_id ' ] = $ this ->_storeCodeToId [$ rowData [self ::COLUMN_STORE ]];
488
488
} else {
@@ -702,7 +702,7 @@ private function getCustomerStoreId(string $email, string $websiteCode)
702
702
$ storeId = $ this ->getCustomerStorage ()->getCustomerStoreId ($ email , $ websiteId );
703
703
if ($ storeId === null || $ storeId === false ) {
704
704
$ defaultStore = $ this ->_storeManager ->getWebsite ($ websiteId )->getDefaultStore ();
705
- $ storeId = $ defaultStore ? $ defaultStore ->getId () : \ Magento \ Store \ Model \ Store::DEFAULT_STORE_ID ;
705
+ $ storeId = $ defaultStore ? $ defaultStore ->getId () : Store::DEFAULT_STORE_ID ;
706
706
}
707
707
return $ storeId ;
708
708
}
0 commit comments