Skip to content

Commit 5392108

Browse files
committed
Merge remote-tracking branch 'origin/MC-17200' into 2.2-develop-pr35
2 parents 78b4826 + 2522430 commit 5392108

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
7-
86
declare(strict_types=1);
97

108
namespace Magento\Customer\Model\Delegation;
@@ -21,6 +19,7 @@
2119
use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
2220
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
2321
use Magento\Customer\Api\Data\AddressInterfaceFactory;
22+
use Magento\Framework\Api\CustomAttributesDataInterface;
2423
use Psr\Log\LoggerInterface;
2524

2625
/**
@@ -104,11 +103,13 @@ public function storeNewOperation(
104103
}
105104
}
106105
$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+
);
112113
}
113114

114115
/**
@@ -138,18 +139,31 @@ public function consumeNewOperation()
138139
);
139140
$addressData['region'] = $region;
140141
}
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(
142150
['data' => $addressData]
143151
);
152+
153+
foreach ($customAttributes as $attributeCode => $attributeValue) {
154+
$address->setCustomAttribute($attributeCode, $attributeValue);
155+
}
156+
157+
$addresses[] = $address;
144158
}
145159
$customerData = $serialized['customer'];
146160
$customerData['addresses'] = $addresses;
147161

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+
);
154168
}
155169
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Sales\Api;
87

98
use Magento\Customer\Api\AccountManagementInterface;
@@ -17,6 +16,8 @@
1716
use PHPUnit\Framework\TestCase;
1817

1918
/**
19+
* Test for Magento\Sales\Api\OrderCustomerDelegateInterface class
20+
*
2021
* @magentoAppIsolation enabled
2122
*/
2223
class OrderCustomerDelegateInterfaceTest extends TestCase
@@ -47,7 +48,7 @@ class OrderCustomerDelegateInterfaceTest extends TestCase
4748
private $orderFactory;
4849

4950
/**
50-
* @inheritDoc
51+
* @inheritdoc
5152
*/
5253
protected function setUp()
5354
{
@@ -123,6 +124,7 @@ private function compareAddresses(
123124
/**
124125
* @magentoDbIsolation enabled
125126
* @magentoAppIsolation enabled
127+
* @magentoDataFixture Magento/Customer/_files/attribute_user_defined_address.php
126128
* @magentoDataFixture Magento/Sales/_files/order.php
127129
*/
128130
public function testDelegateNew()
@@ -131,7 +133,7 @@ public function testDelegateNew()
131133
/** @var Order $orderModel */
132134
$orderModel = $this->orderFactory->create();
133135
$orderModel->loadByIncrementId($orderAutoincrementId);
134-
$orderId = $orderModel->getId();
136+
$orderId = (int)$orderModel->getId();
135137
unset($orderModel);
136138

137139
$this->delegate->delegateNew($orderId);

0 commit comments

Comments
 (0)