Skip to content

Commit 5223ed0

Browse files
committed
MC-17201: Delegated account creation fails with custom attributes present in customer address
1 parent 2e7f039 commit 5223ed0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
2020
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
2121
use Magento\Customer\Api\Data\AddressInterfaceFactory;
22+
use Magento\Framework\Api\CustomAttributesDataInterface;
2223
use Psr\Log\LoggerInterface;
2324

2425
/**
@@ -134,9 +135,22 @@ public function consumeNewOperation()
134135
);
135136
$addressData['region'] = $region;
136137
}
137-
$addresses[] = $this->addressFactory->create(
138+
139+
$customAttributes = [];
140+
if (!empty($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) {
141+
$customAttributes = $addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES];
142+
unset($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]);
143+
}
144+
145+
$address = $this->addressFactory->create(
138146
['data' => $addressData]
139147
);
148+
149+
foreach ($customAttributes as $attributeCode => $attributeValue) {
150+
$address->setCustomAttribute($attributeCode, $attributeValue);
151+
}
152+
153+
$addresses[] = $address;
140154
}
141155
$customerData = $serialized['customer'];
142156
$customerData['addresses'] = $addresses;

dev/tests/integration/testsuite/Magento/Sales/Api/OrderCustomerDelegateInterfaceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\CustomerInterface;
1313
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
14+
use Magento\Framework\Api\AttributeInterface;
1415
use Magento\Sales\Api\Data\OrderAddressInterface;
1516
use Magento\Sales\Model\Order;
1617
use Magento\Sales\Model\OrderFactory;
@@ -126,6 +127,7 @@ private function compareAddresses(
126127
/**
127128
* @magentoDbIsolation enabled
128129
* @magentoAppIsolation enabled
130+
* @magentoDataFixture Magento/Customer/_files/attribute_user_defined_address.php
129131
* @magentoDataFixture Magento/Sales/_files/order.php
130132
* @return void
131133
*/

0 commit comments

Comments
 (0)