Skip to content
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

Fixed #15059 Cannot reorder from the first try #20893

Closed

Conversation

shikhamis11
Copy link
Member

@shikhamis11 shikhamis11 commented Feb 3, 2019

Fixed #15059 Cannot reorder from the first try

Preconditions

  1. Latest Magento 2.3-develop

Steps to reproduce

  1. Create a Virtual Product
  2. Register a Customer Account
  3. Place an Order with the Virtual Product
  4. Create an Invoice
  5. Try to Reorder

Expected result

exp

exp1

Actual result

act1

act

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 on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11. 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-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

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

@shikhamis11
Copy link
Member Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11, here is your new Magento instance.
Admin access: https://pr-20893.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@@ -269,6 +269,7 @@ public function displayTotalsIncludeTax()
*/
public function getSubtotal()
{
$this->getQuote()->collectTotals()->save();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shikhamis11 thanks for the fix! I think it's better to move quote calculation and save calls to a model. Could you perform these calls from a model or controller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sivaschenko thanks for review . I have updated code in controller Please have a look

@sivaschenko
Copy link
Member

Hi @shikhamis11 , thanks for moving the call to a controller. The issue is that having it in the order/create/index controller will trigger the recalcualtion for both first time order and reorder. Also, such implementation is not following the CQRS principle, as this controller is designed to return information without changing the state of the system.

Can you please move this call to a model or controller that are executed specifically for reorder operation?

@shikhamis11
Copy link
Member Author

I am trying

@shikhamis11
Copy link
Member Author

@sivaschenko Please check my last commit . The reason is that the subtotal updated correctly because the totals block is loaded after the items grid block

@sivaschenko
Copy link
Member

Hi @shikhamis11 you are trying to recalculate quote during rendering, while, in my opinion, the good fix for the issue should be applied to calculating and saving quote correctly the first time - during the call to Magento\Sales\Controller\Adminhtml\Order\Create\Reorder controller.

For the investigation of this issue, I'd compare the flow of reordering a simple product (that works fine) and a virtual product (that results in the issue).

Looks like reorder of virtual product lacks processing of quote address items and quote_item is saved without any price information.

I would start the investigation from \Magento\Sales\Model\AdminOrder\Create::initFromOrder and follow the quote saving process.

In my opinion, the fix for this issue should be applied somewhere around quote relations processing.

@shikhamis11
Copy link
Member Author

@sivaschenko thanks for working on this issue . Yes you are right the problem is somewhere in :initFormOrder I had tried once but didn't get any clue . I will try to debug it again

@shikhamis11
Copy link
Member Author

@sivaschenko while debugging I got to know for billing address the item cache was not unset .Please review my latest changes

@sivaschenko
Copy link
Member

sivaschenko commented Feb 19, 2019

Well done @shikhamis11 ! Finally, can you please squash all the commits into a single one with a meaningful commit message, i.e.: magento/magento2#20893: Fixed #15059 Cannot reorder from the first try

@ghost
Copy link

ghost commented Feb 19, 2019

Hi @shikhamis11, 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.

@shikhamis11
Copy link
Member Author

@sivaschenko after force push there this PR was closed also there in no option to reopen this so I created new one and assigned that to you .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants