diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
index d1a90783c68c7..ad2641577c4a7 100644
--- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
@@ -32,7 +32,7 @@ if ($block->getIsShipping()):
require(["Magento_Sales/order/create/form"], function(){
order.shippingAddressContainer = '= /* @escapeNotVerified */ $_fieldsContainerId ?>';
- order.setAddresses(= /* @escapeNotVerified */ $customerAddressFormatter->getAddressesJson($addressArray) ?>);
+ order.setAddresses(= /* @escapeVerfied */ $block->getAddressCollectionJson() ?>);
});
diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php b/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php
index 538f4e646d060..e51788ad9ecf5 100644
--- a/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php
+++ b/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php
@@ -45,6 +45,30 @@ public function toNestedArray(
}
$dataObjectArray = $this->dataObjectProcessor->buildOutputDataArray($dataObject, $dataObjectType);
//process custom attributes if present
+ $dataObjectArray = $this->processCustomAttributes($dataObjectArray, $skipAttributes);
+
+ if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
+ /** @var array $extensionAttributes */
+ $extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
+ unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
+ foreach ($extensionAttributes as $attributeKey => $attributeValue) {
+ if (!in_array($attributeKey, $skipAttributes)) {
+ $dataObjectArray[$attributeKey] = $attributeValue;
+ }
+ }
+ }
+ return $dataObjectArray;
+ }
+
+ /**
+ * Recursive process array to process customer attributes
+ *
+ * @param array $dataObjectArray
+ * @param array $skipAttributes
+ * @return array
+ */
+ private function processCustomAttributes(array $dataObjectArray, array $skipAttributes): array
+ {
if (!empty($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) {
/** @var AttributeValue[] $customAttributes */
$customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY];
@@ -56,14 +80,9 @@ public function toNestedArray(
}
}
}
- if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
- /** @var array $extensionAttributes */
- $extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
- unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
- foreach ($extensionAttributes as $attributeKey => $attributeValue) {
- if (!in_array($attributeKey, $skipAttributes)) {
- $dataObjectArray[$attributeKey] = $attributeValue;
- }
+ foreach ($dataObjectArray as $key => $value) {
+ if (is_array($value)) {
+ $dataObjectArray[$key] = $this->processCustomAttributes($value, $skipAttributes);
}
}
return $dataObjectArray;
diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php
index f0e333aa5e1d5..e362d652b7a13 100644
--- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php
+++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensibleDataObjectConverterTest.php
@@ -83,6 +83,17 @@ public function testToNestedArrayCustom()
AttributeValue::VALUE => 'custom_attribute_value_skip',
],
],
+ 'test' => [
+ 0 => [
+ '3rd_attribute_key' => '3rd_attribute_value',
+ AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY => [
+ [
+ AttributeValue::ATTRIBUTE_CODE => 'another_custom_attribute_code',
+ AttributeValue::VALUE => 'another_custom_attribute_value',
+ ]
+ ]
+ ]
+ ]
];
$resultArray = [
@@ -92,6 +103,12 @@ public function testToNestedArrayCustom()
'custom_attribute_value_multi_1',
'custom_attribute_value_multi_2',
],
+ 'test' => [
+ 0 => [
+ '3rd_attribute_key' => '3rd_attribute_value',
+ 'another_custom_attribute_code' => 'another_custom_attribute_value',
+ ]
+ ]
];
$this->processor->expects($this->any())