-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#22998 : failing order creation with api when no address email is provided #23048
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
#22998 : failing order creation with api when no address email is provided #23048
Conversation
Hi @Wirson. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Wirson,
thank you for your contribution!
Unfortunately, the current solution is rather a workaround and it does not seem to be solving the real issue.
The issue should have appeared because of the setter methods called by the Webapi Service Input Processor in the same order as the properties are provided in a payload. I would say this is the framework issue and would be better to normalize the data provided in payload etc.
However, in this particluar case, the setter methods are implemented unproperly.
\Magento\Sales\Model\Order::setBillingAddress
\Magento\Sales\Model\Order::setShippingAddress
Having a logic within a setter method is bad practice.
So I would recommend fixing the issue by refactoring these two methods if it's possible.
Thank you!
I was going through rest api request processing line by line, and I did not find a way to influence the request from outside webapi or framework module. Also, refactoring setBillingAddress() will not change anything in this matter if there is no email in order object yet. Any clues? |
After performing the internal checks I could not find a better entry point for the fix. |
Hi @dmytro-ch, thank you for the review.
|
✔️ QA Passed |
…address email is provided magento#23048
Hi @Wirson, thank you for your contribution! |
Description (*)
When billing address data is before customer data in order create api JSON payload, the billing address email is not populated. see https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Sales/Model/Order.php#L997 . Order is empty, so customer email is nowhere to be brought from.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
I am not sure whether this is the best solution.
Contribution checklist (*)