Skip to content

Commit 1b791a6

Browse files
committed
Merge remote-tracking branch 'origin/MC-17201' into 2.3-develop-pr29
2 parents a81d416 + 52d6786 commit 1b791a6

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

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

Lines changed: 28 additions & 12 deletions
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
/**
@@ -100,11 +101,13 @@ public function storeNewOperation(CustomerInterface $customer, array $delegatedD
100101
}
101102
}
102103
$this->session->setCustomerFormData($customerData);
103-
$this->session->setDelegatedNewCustomerData([
104-
'customer' => $customerData,
105-
'addresses' => $addressesData,
106-
'delegated_data' => $delegatedData,
107-
]);
104+
$this->session->setDelegatedNewCustomerData(
105+
[
106+
'customer' => $customerData,
107+
'addresses' => $addressesData,
108+
'delegated_data' => $delegatedData,
109+
]
110+
);
108111
}
109112

110113
/**
@@ -134,18 +137,31 @@ public function consumeNewOperation()
134137
);
135138
$addressData['region'] = $region;
136139
}
137-
$addresses[] = $this->addressFactory->create(
140+
141+
$customAttributes = [];
142+
if (!empty($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) {
143+
$customAttributes = $addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES];
144+
unset($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]);
145+
}
146+
147+
$address = $this->addressFactory->create(
138148
['data' => $addressData]
139149
);
150+
151+
foreach ($customAttributes as $attributeCode => $attributeValue) {
152+
$address->setCustomAttribute($attributeCode, $attributeValue);
153+
}
154+
155+
$addresses[] = $address;
140156
}
141157
$customerData = $serialized['customer'];
142158
$customerData['addresses'] = $addresses;
143159

144-
return $this->newFactory->create([
145-
'customer' => $this->customerFactory->create(
146-
['data' => $customerData]
147-
),
148-
'additionalData' => $serialized['delegated_data'],
149-
]);
160+
return $this->newFactory->create(
161+
[
162+
'customer' => $this->customerFactory->create(['data' => $customerData]),
163+
'additionalData' => $serialized['delegated_data'],
164+
]
165+
);
150166
}
151167
}

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)