-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Magento 2.3.4 Quote Address Extension Attribute Issue #26682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening this issue! |
Hi @NathMorgan. Thank you for your report.
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:
For more details, please, review the Magento Contributor Assistant documentation. @NathMorgan do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Thanks for opening this issue! |
Currently working on a fix |
Hi @NathMorgan. Thank you for working on this issue.
|
This seems to be specifically caused by 6900c38#diff-0dba08a1fa5d66da0b3c252c4949907eR106 which populates the extension attribute. Then when it passes through https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Quote/Model/ShippingMethodManagement.php#L312 it will be converted to array by the This could be a 'custom' implementation error only, because this will only happen if the discount collector is called before (any public function that depends on On a side note; this would also cause errors if any other extension attribute is added that doesn't default to |
Dug in a little deeper and in my opinion the solution / problem is this line https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Quote/Model/ShippingMethodManagement.php#L312 I think there are two solutions to the problem:
The second option is the easiest to implement but doen't really 'fix' the issue, it just works around the issue in a non-standard way. Edit: Strike the first solution. I thought the ServiceInputProcessor could be used as a 'hydrator' but it can not. This would require some ugly recursive merge which would most definitely cause issues. |
@Swahjak Sadly the 2nd method is not as simple due to the fact that the |
@NathMorgan are you still working on this? Is there any WIP branch or workaround? |
For our case the following patch seems to work. We just avoid overwriting the extension_attributes. Is is really necessary to overwrite them using extractAddressData() ? I think it is just a sideeffect and extension attributes should not be overwritten in that way
|
I tried @amenk 's patch and it seems to work. My only doubt is whether the same thing should be done for "custom attributes" as well. In case anyone else wants to try that same patch without editing the core, I turned it onto a diff that can be applied automatically with Composer Patches. Just save this diff into a file and configure Composer Patches to apply it to the magento/module-quote module:
|
Thanks @azambon . You can also get a diff by adding .diff to the PR's URL: https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/27338.diff Can even be referenced from composer patches directly. |
Hmm, are you sure that it works using the straight PR diff? Am I missing something? |
In composer-patches there is a level-parameter which was just invented for that :) |
@amenk Didn't know about that parameter. I'll look into it. Thank you 👍 |
Hi, This issue was already fixed in 2.4-develop branch in fcd1b58#diff-e2b9d1a5f4b9f3503a2f8dd072bc2d8aR360. Additional test coverage will be also added in #27338. |
Hi @NathMorgan. Thank you for your report.
The fix will be available with the upcoming 2.4.1 release. |
Preconditions (*)
Magento\Quote\Api\Data\AddressInterface
Example module here: https://github.com/NathMorgan/module-test-moduleSteps to reproduce (*)
estimate-shipping-methods
containing aextension_attributes
For example a post request to
/rest/default/V1/guest-carts/{cartId}/estimate-shipping-methods
with the following example data{"address":{"street":["Example High Street"],"city":"Example City","region_id":null,"region":null,"country_id":"GB","postcode":"TES 01","company":"Example Company","telephone":"0000 00000","fax":null,"extension_attributes":{"test_attribute":"2"}}}
Expected result (*)
Actual result (*)
Uncaught Error: Call to a member function setDiscounts() on array in /var/www/html/vendor/magento/module-sales-rule/Model/Quote/Discount.php: 117
This issue seems to be introduced with this commit: 6900c38
This seems to effect any extension attribute set on
Magento\Quote\Api\Data\AddressInterface
that is not a objectThe text was updated successfully, but these errors were encountered: