diff --git a/app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer/Storage.php b/app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer/Storage.php index ae88e9672c9f4..67717fa371625 100644 --- a/app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer/Storage.php +++ b/app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Customer/Storage.php @@ -76,16 +76,17 @@ public function __construct( public function load() { if ($this->_isCollectionLoaded == false) { - $collection = clone $this->_customerCollection; - $collection->removeAttributeToSelect(); - $tableName = $collection->getResource()->getEntityTable(); - $collection->getSelect()->from($tableName, ['entity_id', 'website_id', 'email']); - - $this->_byPagesIterator->iterate( - $this->_customerCollection, - $this->_pageSize, - [[$this, 'addCustomer']] - ); + $connection = $this->_customerCollection->getConnection(); + $select = $connection->select(); + $select->from($this->_customerCollection->getMainTable(), ['entity_id', 'website_id', 'email']); + $results = $connection->fetchAll($select); + foreach ($results as $customer) { + $email = strtolower(trim($customer['email'])); + if (!isset($this->_customerIds[$email])) { + $this->_customerIds[$email] = []; + } + $this->_customerIds[$email][$customer['website_id']] = $customer['entity_id']; + } $this->_isCollectionLoaded = true; }