AbstractAddress setData('custom_attributes', AttributeValue[]) breaks customAttributes
Preconditions (*)
- Magento 2.4.1
Steps to reproduce (*)
- Add custom attribute on customer address
- Call
$address->setCustomAttributes('custom_attributes', $attributes)where$attributesis Magento\Framework\Api\AttributeValue Note that this is done several times in the checkout process if the custom attribute is added on the payload(i.e is present in the form). For example in \Magento\Quote\Model\ShippingMethodManagement::estimateByExtendedAddress()
Expected result (*)
- Custom attributes are added on the entity with their initial values
Actual result (*)
- The value of the custom attributes also contains the attribute code. This can be easily be debugged starting from AbstractAddress::setData() AbstractExtensibleModel::setData() and finally AbstractExtensibleModel::filterCustomAttributes() to this lines
foreach ($data[self::CUSTOM_ATTRIBUTES] as $code => $value) {
if (!($value instanceof \Magento\Framework\Api\AttributeInterface)) {
$data[self::CUSTOM_ATTRIBUTES][$code] = $this->customAttributeFactory->create()
->setAttributeCode($code)
->setValue($value);
}
}
where $value is an array that contains both the code and the value of the attribute because of this line in AbstractAddress::setData()
$attribute = is_array($attribute) ? $attribute : $attribute->__toArray();
I don't know what to say about the severity. This is pretty severe in my book, but the levels only seem to take into account a clean Magento install which I bet there isn't a single one in production.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @victortodoran. Thank you for your report. To help us process this issue please make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance - upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
- Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
I can confirm this is happening on Magento 2.4.1
It looks like everything started with this commit https://github.com/magento/magento2/commit/91d61bdc5e5b85dcc5b51f7b539055e187a16790 which was meant to allow the multiline custom attributes to be saved
@barbazul thanks for taking the time to confirm this.
This issue still has the status Ready For Confirmation. Why is that?
I can confirm this is happening on Magento 2.4.1 (Magento Cloud)
Summary of the issue The custom address attributes doesn't save information as expected.
Information on your environment The error was confirmed on a clean Magento 2.4.1 installation.
Steps to reproduce:
- Create a client address atribute type "input_text" and another type "dropdown"
- Make a purchase and check the attributes on the admin.
- The error its visible on the admin when you edit the address of the order on guest purchases.
- The error can also be seen on the admin when you edit the client address. on registered customers purchases
Expected and actual results The custom address attributes doesn't save information as expected. You can see attach files.
We have a open ticket in Magento Cloud Help Center for this issue: https://support.magento.com/hc/en-us/requests/381435
@magento-admin do you have a patch for this? it seems that in Magento 2.4.2 it is solved.
Regards, Maximiliano.

Found this bug today, upgrading to 2.4.2 an existing website that has custom attributes for customer address.
Since i'm not using multiline custom attributes i simply made a patch to remove the changes from commit https://github.com/magento/magento2/commit/91d61bdc5e5b85dcc5b51f7b539055e187a16790, if someone needs it:
Index: vendor/magento/module-customer/Model/Address/AbstractAddress.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/module-customer/Model/Address/AbstractAddress.php b/vendor/magento/module-customer/Model/Address/AbstractAddress.php
--- a/vendor/magento/module-customer/Model/Address/AbstractAddress.php (date 1615480763891)
+++ b/vendor/magento/module-customer/Model/Address/AbstractAddress.php (date 1615480763891)
@@ -281,11 +281,6 @@
$key = $this->_implodeArrayField($key);
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$value = $this->_implodeArrayValues($value);
- } elseif (self::CUSTOM_ATTRIBUTES === $key && is_array($value)) {
- foreach ($value as &$attribute) {
- $attribute = is_array($attribute) ? $attribute : $attribute->__toArray();
- $attribute = $this->processCustomAttribute($attribute);
- }
}
return parent::setData($key, $value);
Found this bug today, upgrading to 2.4.2 an existing website that has custom attributes for customer address.
Since i'm not using multiline custom attributes i simply made a patch to remove the changes from commit 91d61bd, if someone needs it:
Index: vendor/magento/module-customer/Model/Address/AbstractAddress.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-customer/Model/Address/AbstractAddress.php b/vendor/magento/module-customer/Model/Address/AbstractAddress.php --- a/vendor/magento/module-customer/Model/Address/AbstractAddress.php (date 1615480763891) +++ b/vendor/magento/module-customer/Model/Address/AbstractAddress.php (date 1615480763891) @@ -281,11 +281,6 @@ $key = $this->_implodeArrayField($key); } elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) { $value = $this->_implodeArrayValues($value); - } elseif (self::CUSTOM_ATTRIBUTES === $key && is_array($value)) { - foreach ($value as &$attribute) { - $attribute = is_array($attribute) ? $attribute : $attribute->__toArray(); - $attribute = $this->processCustomAttribute($attribute); - } } return parent::setData($key, $value);
Thanks @slackerzz!
Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.4-develop instance
Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Hotel, here is your Magento Instance: https://16d30920407fe7280410e4814aea87b6-2-4-develop.instances.magento-community.engineering Admin access: https://16d30920407fe7280410e4814aea87b6-2-4-develop.instances.magento-community.engineering/admin_b34e Login: 058a3638 Password: b6d16030587b
@magento give me 2.4-develop instance
Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Hotel, here is your Magento Instance: https://16d30920407fe7280410e4814aea87b6-2-4-develop.instances.magento-community.engineering Admin access: https://16d30920407fe7280410e4814aea87b6-2-4-develop.instances.magento-community.engineering/admin_7683 Login: 60996cfe Password: f6755d7eaa97
Hello @victortodoran,
We have tried to reproduce the issue in Magento 2.4-develop branch with the steps mentioned in comment. But the issue is not reproducible. Please have a look into below screenshots for reference:
Customer Attribute page

Admin Billing Order Edit page

Admin Shiping Order Edit page

Please let us know in case we have missed anything in order to reproduce the issue.
Thanks
Hello @victortodoran,
We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket if you need more assistance on this.
Regards
This issue is still there after 2 years.
-
\Magento\Customer\Model\Address\AbstractAddress::setData l.284 is still converting custom_attributes into an array to process the private function "processCustomAttribute"
-
being interpreted as
-
causing save in DB as :
@victortodoran are you still facing this issue on 2.4.4-p2 aswell?
I approve that on 2.4.6 this issue is still too:
Hello @Litvinenko-Sergey,
Thanks for the update, we are opening this issue for further analysis.
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @Litvinenko-Sergey,
Thank you for the report!
We have tried to reproduce this on vanilla installation of 2.4-develop.
We created two custom address attributes one with text and one with dropdown, as mentioned here https://github.com/magento/magento2/issues/31644#issuecomment-789300004, but we are able to save the value of the custom attributes without any issues.
Please take a look at the screenshot below:
We also checked with the debugger:
And we didn't see any array returned for the
value attribute.
Please let us know if we are missing anything.
Thank you.
I reproduced it on vanilla magento 2.4.6. I created a simple module that helps you to reproduce this bug:
Litvinenko.zip
You just need to install this module and create an order on frontend like guest.
Hello @Litvinenko-Sergey,
Thank you for the quick reply!
We were able to reproduce this issue on 2.4-develop.
We have used your custom module to reproduce this issue.
Please take a look at the screenshot below:
The custom address attribute value is not being saved.
And we can see that the value also has custom attribute code.
Hence confirming this issue.
Thank you.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10568 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-10568
Hi @victortodoran,
Adobe Commerce Engineering team started working on this issue. We will reach out to you if we need more information and you will get notified once the issue is fixed. Please leave comments for any further questions.
Thank you!