Skip to content

Commit ba93ede

Browse files
committed
Merge branch 'ACP2E-2798' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-03-12-2024-anna
2 parents 6b088e9 + 8e7285e commit ba93ede

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,21 +342,25 @@ public function _construct()
342342
public function getDataModel()
343343
{
344344
$customerData = $this->getData();
345-
$addressesData = [];
345+
$regularAddresses = $defaultAddresses = [];
346346
/** @var \Magento\Customer\Model\Address $address */
347347
foreach ($this->getAddresses() as $address) {
348348
if (!isset($this->storedAddress[$address->getId()])) {
349349
$this->storedAddress[$address->getId()] = $address->getDataModel();
350350
}
351-
$addressesData[] = $this->storedAddress[$address->getId()];
351+
if ($this->storedAddress[$address->getId()]->isDefaultShipping()) {
352+
$defaultAddresses[] = $this->storedAddress[$address->getId()];
353+
} else {
354+
$regularAddresses[] = $this->storedAddress[$address->getId()];
355+
}
352356
}
353357
$customerDataObject = $this->customerDataFactory->create();
354358
$this->dataObjectHelper->populateWithArray(
355359
$customerDataObject,
356360
$customerData,
357361
\Magento\Customer\Api\Data\CustomerInterface::class
358362
);
359-
$customerDataObject->setAddresses($addressesData)
363+
$customerDataObject->setAddresses(array_merge($defaultAddresses, $regularAddresses))
360364
->setId($this->getId());
361365
return $customerDataObject;
362366
}

app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<?php declare(strict_types=1);
2-
/**
3-
* Unit test for customer service layer \Magento\Customer\Model\Customer
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
46
*
5-
* Copyright © Magento, Inc. All rights reserved.
6-
* See COPYING.txt for license details.
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
716
*/
817

918
/**
@@ -387,6 +396,7 @@ public function testGetDataModel()
387396
$this->_model->setEntityId($customerId);
388397
$this->_model->setId($customerId);
389398
$addressDataModel = $this->getMockForAbstractClass(AddressInterface::class);
399+
$addressDataModel->expects($this->exactly(4))->method('isDefaultShipping')->willReturn(true);
390400
$address = $this->getMockBuilder(AddressModel::class)
391401
->disableOriginalConstructor()
392402
->setMethods(['setCustomer', 'getDataModel'])

0 commit comments

Comments
 (0)