|
19 | 19 | use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
|
20 | 20 | use Magento\Customer\Api\Data\CustomerInterfaceFactory;
|
21 | 21 | use Magento\Customer\Api\Data\AddressInterfaceFactory;
|
| 22 | +use Magento\Framework\Api\CustomAttributesDataInterface; |
22 | 23 | use Psr\Log\LoggerInterface;
|
23 | 24 |
|
24 | 25 | /**
|
@@ -100,11 +101,13 @@ public function storeNewOperation(CustomerInterface $customer, array $delegatedD
|
100 | 101 | }
|
101 | 102 | }
|
102 | 103 | $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 | + ); |
108 | 111 | }
|
109 | 112 |
|
110 | 113 | /**
|
@@ -134,18 +137,31 @@ public function consumeNewOperation()
|
134 | 137 | );
|
135 | 138 | $addressData['region'] = $region;
|
136 | 139 | }
|
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( |
138 | 148 | ['data' => $addressData]
|
139 | 149 | );
|
| 150 | + |
| 151 | + foreach ($customAttributes as $attributeCode => $attributeValue) { |
| 152 | + $address->setCustomAttribute($attributeCode, $attributeValue); |
| 153 | + } |
| 154 | + |
| 155 | + $addresses[] = $address; |
140 | 156 | }
|
141 | 157 | $customerData = $serialized['customer'];
|
142 | 158 | $customerData['addresses'] = $addresses;
|
143 | 159 |
|
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 | + ); |
150 | 166 | }
|
151 | 167 | }
|
0 commit comments