Skip to content

Commit ca7aa05

Browse files
committed
MAGETWO-97411: \Magento\Customer\Model\Customer::getDataModel method takes to much time to load with many addresses customer
1 parent 868b19f commit ca7aa05

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/code/Magento/Customer/Model/Customer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,23 @@ public function _construct()
318318
public function getDataModel()
319319
{
320320
$customerData = $this->getData();
321-
if (!isset($this->storedAddress[$customerData['entity_id']])) {
321+
if (isset($customerData['entity_id']) && !isset($this->storedAddress[$customerData['entity_id']])) {
322322
$addressesData = [];
323323
/** @var \Magento\Customer\Model\Address $address */
324324
foreach ($this->getAddresses() as $address) {
325325
$addressesData[] = $address->getDataModel();
326326
}
327327
$this->storedAddress[$customerData['entity_id']] = $addressesData;
328+
} elseif (isset($customerData['entity_id'], $this->storedAddress[$customerData['entity_id']])) {
329+
$customerData = $this->storedAddress[$customerData['entity_id']];
328330
}
329331
$customerDataObject = $this->customerDataFactory->create();
330332
$this->dataObjectHelper->populateWithArray(
331333
$customerDataObject,
332334
$customerData,
333335
\Magento\Customer\Api\Data\CustomerInterface::class
334336
);
335-
$customerDataObject->setAddresses($this->storedAddress[$customerData['entity_id']])
337+
$customerDataObject->setAddresses($customerData)
336338
->setId($this->getId());
337339
return $customerDataObject;
338340
}

0 commit comments

Comments
 (0)