Skip to content

Commit

Permalink
magento-engcom/import-export-improvements#43: make the customer impor…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
dmanners committed Jan 17, 2018
1 parent 14eeea2 commit f148e35
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f148e35

Please sign in to comment.