Skip to content

Commit fc62e0c

Browse files
committed
ACP2E-3165: [Cloud] Getting error while checking the data in import data using CSV
- Fixed the CR comments.
1 parent c7b6d9c commit fc62e0c

File tree

1 file changed

+11
-8
lines changed
  • app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer

1 file changed

+11
-8
lines changed

app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer/Storage.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,22 @@ private function loadCustomersData(array $customerIdentifiers): void
104104
};
105105
$offset = 0;
106106
for ($chunk = $getChuck($offset); !empty($chunk); $offset += $pageSize, $chunk = $getChuck($offset)) {
107-
$emails = array_column($chunk, 'email');
107+
$customerWebsites = array_reduce($chunk, function($customerWebsiteByEmail, $customer) {
108+
$customerWebsiteByEmail[$customer['email']][] = $customer['website_id'];
109+
return $customerWebsiteByEmail;
110+
});
108111
$chunkSelect = clone $select;
109-
$chunkSelect->where($customerTableId . '.email IN (?)', $emails);
112+
$chunkSelect->where($customerTableId . '.email IN (?)', array_keys($customerWebsites));
110113
$customers = $collection->getConnection()->fetchAll($chunkSelect);
114+
$i = 0;
111115
foreach ($customers as $customer) {
112116
$this->addCustomerByArray($customer);
113-
if ($this->configShare->isGlobalScope() &&
114-
is_array(current($customerIdentifiers)) &&
115-
count(current($customerIdentifiers)) > 0 &&
116-
isset(current($customerIdentifiers)['website_id']) &&
117-
$customer['website_id'] !== (string) current($customerIdentifiers)['website_id']
117+
if (
118+
$this->configShare->isGlobalScope() &&
119+
!in_array((int) $customer['website_id'], $customerWebsites[$customer['email']], true)
118120
) {
119-
$customer['website_id'] = (string) current($customerIdentifiers)['website_id'];
121+
$customer['website_id'] = $customerWebsites[$customer['email']][$i];
122+
$i++;
120123
$this->addCustomerByArray($customer);
121124
}
122125
}

0 commit comments

Comments
 (0)