Skip to content

Commit 4109cdb

Browse files
committed
Merge remote-tracking branch 'tango/MAGETWO-99451' into PR-05
2 parents f270f29 + 149d8eb commit 4109cdb

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if ($block->getIsShipping()):
3232
require(["Magento_Sales/order/create/form"], function(){
3333

3434
order.shippingAddressContainer = '<?= /* @escapeNotVerified */ $_fieldsContainerId ?>';
35-
order.setAddresses(<?= /* @escapeNotVerified */ $customerAddressFormatter->getAddressesJson($addressArray) ?>);
35+
order.setAddresses(<?= /* @escapeVerfied */ $block->getAddressCollectionJson() ?>);
3636

3737
});
3838
</script>

lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ public function toNestedArray(
4545
}
4646
$dataObjectArray = $this->dataObjectProcessor->buildOutputDataArray($dataObject, $dataObjectType);
4747
//process custom attributes if present
48+
$dataObjectArray = $this->processCustomAttributes($dataObjectArray, $skipAttributes);
49+
50+
if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
51+
/** @var array $extensionAttributes */
52+
$extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
53+
unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
54+
foreach ($extensionAttributes as $attributeKey => $attributeValue) {
55+
if (!in_array($attributeKey, $skipAttributes)) {
56+
$dataObjectArray[$attributeKey] = $attributeValue;
57+
}
58+
}
59+
}
60+
return $dataObjectArray;
61+
}
62+
63+
/**
64+
* Recursive process array to process customer attributes
65+
*
66+
* @param array $dataObjectArray
67+
* @param array $skipAttributes
68+
* @return array
69+
*/
70+
private function processCustomAttributes(array $dataObjectArray, array $skipAttributes): array
71+
{
4872
if (!empty($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) {
4973
/** @var AttributeValue[] $customAttributes */
5074
$customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY];
@@ -56,14 +80,9 @@ public function toNestedArray(
5680
}
5781
}
5882
}
59-
if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
60-
/** @var array $extensionAttributes */
61-
$extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
62-
unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
63-
foreach ($extensionAttributes as $attributeKey => $attributeValue) {
64-
if (!in_array($attributeKey, $skipAttributes)) {
65-
$dataObjectArray[$attributeKey] = $attributeValue;
66-
}
83+
foreach ($dataObjectArray as $key => $value) {
84+
if (is_array($value)) {
85+
$dataObjectArray[$key] = $this->processCustomAttributes($value, $skipAttributes);
6786
}
6887
}
6988
return $dataObjectArray;

lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ public function testToNestedArrayCustom()
8383
AttributeValue::VALUE => 'custom_attribute_value_skip',
8484
],
8585
],
86+
'test' => [
87+
0 => [
88+
'3rd_attribute_key' => '3rd_attribute_value',
89+
AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY => [
90+
[
91+
AttributeValue::ATTRIBUTE_CODE => 'another_custom_attribute_code',
92+
AttributeValue::VALUE => 'another_custom_attribute_value',
93+
]
94+
]
95+
]
96+
]
8697
];
8798

8899
$resultArray = [
@@ -92,6 +103,12 @@ public function testToNestedArrayCustom()
92103
'custom_attribute_value_multi_1',
93104
'custom_attribute_value_multi_2',
94105
],
106+
'test' => [
107+
0 => [
108+
'3rd_attribute_key' => '3rd_attribute_value',
109+
'another_custom_attribute_code' => 'another_custom_attribute_value',
110+
]
111+
]
95112
];
96113

97114
$this->processor->expects($this->any())

0 commit comments

Comments
 (0)