Skip to content

#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

Conversation

Wirson
Copy link
Contributor

@Wirson Wirson commented May 29, 2019

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)

  1. POST on /orders fails when properties in the body are out of sequence #22998 : POST on /orders fails when properties in the body are out of sequence

Manual testing scenarios (*)

  1. use provided JSON payloads but fill it with your data
  2. to fail, simply put billing address as first node.

Questions or comments

I am not sure whether this is the best solution.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented May 29, 2019

Hi @Wirson. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

Copy link
Contributor

@dmytro-ch dmytro-ch left a 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!

@Wirson
Copy link
Contributor Author

Wirson commented May 30, 2019

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?

@dmytro-ch
Copy link
Contributor

After performing the internal checks I could not find a better entry point for the fix.
I think we may ignore the Semantic Version Checker warning, considering the beforeSave public method already exists in the parent class.

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, thank you for the review.
ENGCOM-5312 has been created to process this Pull Request
✳️ @dmytro-ch, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Delta
Copy link
Contributor

✔️ QA Passed

@m2-assistant
Copy link

m2-assistant bot commented Jul 1, 2019

Hi @Wirson, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.3 milestone Jul 1, 2019
@sidolov sidolov added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants