11 use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
13 use Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory;
49 private $customerCollectionFactory;
57 CustomerCollectionFactory $collectionFactory,
58 CollectionByPagesIteratorFactory $colIteratorFactory,
61 $this->_customerCollection = isset(
62 $data[
'customer_collection']
63 ) ?
$data[
'customer_collection'] : $collectionFactory->create();
64 $this->_pageSize = isset(
$data[
'page_size']) ?
$data[
'page_size'] : 0;
65 $this->_byPagesIterator = isset(
66 $data[
'collection_by_pages_iterator']
67 ) ?
$data[
'collection_by_pages_iterator'] : $colIteratorFactory->create();
68 $this->customerCollectionFactory = $collectionFactory;
78 private function prepareCollection(array $customerIdentifiers): CustomerCollection
81 $collection = $this->customerCollectionFactory->create();
86 $customerTableId .
'.email in (?)',
105 private function loadCustomersData(array $customerIdentifiers)
107 $this->_byPagesIterator->iterate(
108 $this->prepareCollection($customerIdentifiers),
110 [[$this,
'addCustomer']]
121 if (!isset($this->_customerIds[
$email])) {
122 $this->_customerIds[
$email] = [];
158 if (!array_key_exists(
$email, $this->_customerIds) || !array_key_exists(
$websiteId, $this->_customerIds[
$email])
160 $this->loadCustomersData([[
'email' =>
$email,
'website_id' =>
$websiteId]]);
179 foreach ($customersToFind as $customerToFind) {
180 $email = mb_strtolower($customerToFind[
'email']);
182 if (!array_key_exists(
$email, $this->_customerIds)
187 $uniqueKey =
$email .
'_' .$websiteId;
188 $identifiers[$uniqueKey] = [
193 if (!array_key_exists(
$email, $this->_customerIds)) {
194 $this->_customerIds[
$email] = [];
204 $this->loadCustomersData($identifiers);
__construct(CustomerCollectionFactory $collectionFactory, CollectionByPagesIteratorFactory $colIteratorFactory, array $data=[])
getCustomerId(string $email, int $websiteId)
prepareCustomers(array $customersToFind)
addCustomerByArray(array $customer)
addCustomer(DataObject $customer)