Skip to content

Commit f148e35

Browse files
committed
magento-engcom#43: make the customer import work with large sets of customer data in the database on low memory systems
- replace the usage of the CollectionByPagesIteratorFactory with a fetchAll when loading current customers from the database, this was causing issues because of the extra overhead that the the iterator caused by using objects to store each row's data in this way we can use a similar approach to how the product import loads old skus. See: Magento\Catalog\Model\ResourceModel\Product::getProductEntitiesInfo
1 parent 14eeea2 commit f148e35

File tree

1 file changed

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

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,17 @@ public function __construct(
7676
public function load()
7777
{
7878
if ($this->_isCollectionLoaded == false) {
79-
$collection = clone $this->_customerCollection;
80-
$collection->removeAttributeToSelect();
81-
$tableName = $collection->getResource()->getEntityTable();
82-
$collection->getSelect()->from($tableName, ['entity_id', 'website_id', 'email']);
83-
84-
$this->_byPagesIterator->iterate(
85-
$this->_customerCollection,
86-
$this->_pageSize,
87-
[[$this, 'addCustomer']]
88-
);
79+
$connection = $this->_customerCollection->getConnection();
80+
$select = $connection->select();
81+
$select->from($this->_customerCollection->getMainTable(), ['entity_id', 'website_id', 'email']);
82+
$results = $connection->fetchAll($select);
83+
foreach ($results as $customer) {
84+
$email = strtolower(trim($customer['email']));
85+
if (!isset($this->_customerIds[$email])) {
86+
$this->_customerIds[$email] = [];
87+
}
88+
$this->_customerIds[$email][$customer['website_id']] = $customer['entity_id'];
89+
}
8990

9091
$this->_isCollectionLoaded = true;
9192
}

0 commit comments

Comments
 (0)