-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Performance] Loading order through repository loads the order multiple times from DB. (ShippingBuilder) #36636
Comments
Hi @Nuranto. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @Nuranto, Thanks for the report and collaboration! We need some more information in order to reproduce the issue. As per my understanding, the method magento2/app/code/Magento/Sales/Model/Order/ShippingBuilder.php Lines 75 to 92 in 3e5be99
We can save the value of the output of Thanks |
Hello @engcom-Hotel, I'm not sure we're on the same page. Calling Issue is when we call magento2/app/code/Magento/Sales/Model/OrderRepository.php Lines 130 to 144 in 3e5be99
You can see on line 137 that the order is loaded from database. But line 144 is calling those two lines :
Result is that when we call I think the best thing to do is to replace
and refactor
and finally refactor |
Hello @Nuranto, Thanks for the detailed explanation! We have debugged the code via following the below steps:
4. Try to access My Account page5. The function $this->orderFactory->create()->load($this->getOrderId()) is calling 3 times for order id 2 . Below is the MySQL query fetched from db.log:
Hence confirming the issue. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-7656 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
… from loading order when not needed.
… from loading order when not needed.
The internal team start working on. the issue |
Hi @o-iegorov. Thank you for working on this issue.
|
Summary
Magento 2.4.5-p1
Loading order through repository loads the order three times from DB :
Loads the order from database, then calls setShippingAssignments() which calls TaxManagement::getShippingAssignmentBuilderDependency() which loads the order from database again.
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Sales/Model/Order/ShippingBuilder.php#L79
and
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Sales/Model/Order/ShippingAssignmentBuilder.php#L79
Examples
Steps to reproduce
magento2/app/code/Magento/Sales/Model/OrderRepository.php
Line 137 in 9ef88b4
magento2/app/code/Magento/Sales/Model/Order/ShippingAssignmentBuilder.php
Line 79 in 9ef88b4
magento2/app/code/Magento/Sales/Model/Order/ShippingBuilder.php
Line 79 in 9ef88b4
4. Try to access
My Account
page5. The function
$this->orderFactory->create()->load($this->getOrderId())
is calling 3 times for order id2
. Below is the MySQL query fetched from db.log:Proposed solution
I guess line
$shippingAssignments->setOrderId($order->getEntityId());
should be replaced somehow by
$shippingAssignments->setOrder($order);
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: