@@ -219,6 +219,11 @@ class Customer extends \Magento\Framework\Model\AbstractModel
219
219
*/
220
220
private $ accountConfirmation ;
221
221
222
+ /**
223
+ * @var array
224
+ */
225
+ private $ storedAddress ;
226
+
222
227
/**
223
228
* @param \Magento\Framework\Model\Context $context
224
229
* @param \Magento\Framework\Registry $registry
@@ -311,18 +316,21 @@ public function _construct()
311
316
public function getDataModel ()
312
317
{
313
318
$ customerData = $ this ->getData ();
314
- $ addressesData = [];
315
- /** @var \Magento\Customer\Model\Address $address */
316
- foreach ($ this ->getAddresses () as $ address ) {
317
- $ addressesData [] = $ address ->getDataModel ();
319
+ if (!isset ($ this ->storedAddress [$ customerData ['entity_id ' ]])) {
320
+ $ addressesData = [];
321
+ /** @var \Magento\Customer\Model\Address $address */
322
+ foreach ($ this ->getAddresses () as $ address ) {
323
+ $ addressesData [] = $ address ->getDataModel ();
324
+ }
325
+ $ this ->storedAddress [$ customerData ['entity_id ' ]] = $ addressesData ;
318
326
}
319
327
$ customerDataObject = $ this ->customerDataFactory ->create ();
320
328
$ this ->dataObjectHelper ->populateWithArray (
321
329
$ customerDataObject ,
322
330
$ customerData ,
323
331
\Magento \Customer \Api \Data \CustomerInterface::class
324
332
);
325
- $ customerDataObject ->setAddresses ($ addressesData )
333
+ $ customerDataObject ->setAddresses ($ this -> storedAddress [ $ customerData [ ' entity_id ' ]] )
326
334
->setId ($ this ->getId ());
327
335
return $ customerDataObject ;
328
336
}
@@ -676,10 +684,10 @@ public function getPrimaryAddressIds()
676
684
{
677
685
$ ids = [];
678
686
if ($ this ->getDefaultBilling ()) {
679
- $ ids [] = $ this ->getDefaultBilling ();
687
+ $ ids [' billing_address ' ] = $ this ->getDefaultBilling ();
680
688
}
681
689
if ($ this ->getDefaultShipping ()) {
682
- $ ids [] = $ this ->getDefaultShipping ();
690
+ $ ids [' shipping_address ' ] = $ this ->getDefaultShipping ();
683
691
}
684
692
return $ ids ;
685
693
}
0 commit comments