|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * |
4 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
5 | 4 | * See COPYING.txt for license details.
|
6 | 5 | */
|
7 |
| - |
8 | 6 | declare(strict_types=1);
|
9 | 7 |
|
10 | 8 | namespace Magento\Customer\Model\Delegation;
|
|
21 | 19 | use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
|
22 | 20 | use Magento\Customer\Api\Data\CustomerInterfaceFactory;
|
23 | 21 | use Magento\Customer\Api\Data\AddressInterfaceFactory;
|
| 22 | +use Magento\Framework\Api\CustomAttributesDataInterface; |
24 | 23 | use Psr\Log\LoggerInterface;
|
25 | 24 |
|
26 | 25 | /**
|
@@ -104,11 +103,13 @@ public function storeNewOperation(
|
104 | 103 | }
|
105 | 104 | }
|
106 | 105 | $this->session->setCustomerFormData($customerData);
|
107 |
| - $this->session->setDelegatedNewCustomerData([ |
108 |
| - 'customer' => $customerData, |
109 |
| - 'addresses' => $addressesData, |
110 |
| - 'delegated_data' => $delegatedData |
111 |
| - ]); |
| 106 | + $this->session->setDelegatedNewCustomerData( |
| 107 | + [ |
| 108 | + 'customer' => $customerData, |
| 109 | + 'addresses' => $addressesData, |
| 110 | + 'delegated_data' => $delegatedData, |
| 111 | + ] |
| 112 | + ); |
112 | 113 | }
|
113 | 114 |
|
114 | 115 | /**
|
@@ -138,18 +139,31 @@ public function consumeNewOperation()
|
138 | 139 | );
|
139 | 140 | $addressData['region'] = $region;
|
140 | 141 | }
|
141 |
| - $addresses[] = $this->addressFactory->create( |
| 142 | + |
| 143 | + $customAttributes = []; |
| 144 | + if (!empty($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) { |
| 145 | + $customAttributes = $addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]; |
| 146 | + unset($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]); |
| 147 | + } |
| 148 | + |
| 149 | + $address = $this->addressFactory->create( |
142 | 150 | ['data' => $addressData]
|
143 | 151 | );
|
| 152 | + |
| 153 | + foreach ($customAttributes as $attributeCode => $attributeValue) { |
| 154 | + $address->setCustomAttribute($attributeCode, $attributeValue); |
| 155 | + } |
| 156 | + |
| 157 | + $addresses[] = $address; |
144 | 158 | }
|
145 | 159 | $customerData = $serialized['customer'];
|
146 | 160 | $customerData['addresses'] = $addresses;
|
147 | 161 |
|
148 |
| - return $this->newFactory->create([ |
149 |
| - 'customer' => $this->customerFactory->create( |
150 |
| - ['data' => $customerData] |
151 |
| - ), |
152 |
| - 'additionalData' => $serialized['delegated_data'] |
153 |
| - ]); |
| 162 | + return $this->newFactory->create( |
| 163 | + [ |
| 164 | + 'customer' => $this->customerFactory->create(['data' => $customerData]), |
| 165 | + 'additionalData' => $serialized['delegated_data'], |
| 166 | + ] |
| 167 | + ); |
154 | 168 | }
|
155 | 169 | }
|
0 commit comments