1010use Magento \Customer \Api \Data \CustomerInterface ;
1111use Magento \Customer \Model \Indexer \Processor ;
1212use Magento \Framework \App \ObjectManager ;
13+ use Magento \Framework \Stdlib \DateTime ;
1314use Magento \ImportExport \Model \Import ;
1415use Magento \ImportExport \Model \Import \AbstractSource ;
1516use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
17+ use Magento \Store \Model \Store ;
1618
1719/**
1820 * Customer entity import
@@ -407,11 +409,9 @@ protected function _prepareDataForUpdate(array $rowData)
407409
408410 // entity table data
409411 $ 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 ' ]));
415415 $ emailInLowercase = strtolower (trim ($ rowData [self ::COLUMN_EMAIL ]));
416416 $ newCustomer = false ;
417417 $ entityId = $ this ->_getCustomerId ($ emailInLowercase , $ rowData [self ::COLUMN_WEBSITE ]);
@@ -448,7 +448,7 @@ protected function _prepareDataForUpdate(array $rowData)
448448 $ value = implode (', ' , $ ids );
449449 } elseif ('datetime ' == $ attributeParameters ['type ' ] && !empty ($ value )) {
450450 $ 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 );
452452 }
453453 if (!$ this ->_attributes [$ attributeCode ]['is_static ' ]) {
454454 /** @var $attribute \Magento\Customer\Model\Attribute */
@@ -473,16 +473,16 @@ protected function _prepareDataForUpdate(array $rowData)
473473 // create
474474 $ entityRow ['group_id ' ] = empty ($ rowData ['group_id ' ]) ? self ::DEFAULT_GROUP_ID : $ rowData ['group_id ' ];
475475 $ 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 );
479479 $ entityRow ['website_id ' ] = $ this ->_websiteCodeToId [$ rowData [self ::COLUMN_WEBSITE ]];
480480 $ entityRow ['email ' ] = $ emailInLowercase ;
481481 $ entityRow ['is_active ' ] = 1 ;
482482 $ entitiesToCreate [] = $ entityRow ;
483483 } else {
484484 // edit
485- $ entityRow ['updated_at ' ] = $ now ->format (\ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT );
485+ $ entityRow ['updated_at ' ] = $ now ->format (DateTime::DATETIME_PHP_FORMAT );
486486 if (!empty ($ rowData [self ::COLUMN_STORE ])) {
487487 $ entityRow ['store_id ' ] = $ this ->_storeCodeToId [$ rowData [self ::COLUMN_STORE ]];
488488 } else {
@@ -702,7 +702,7 @@ private function getCustomerStoreId(string $email, string $websiteCode)
702702 $ storeId = $ this ->getCustomerStorage ()->getCustomerStoreId ($ email , $ websiteId );
703703 if ($ storeId === null || $ storeId === false ) {
704704 $ 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 ;
706706 }
707707 return $ storeId ;
708708 }
0 commit comments