Open
Description
Preconditions (*)
- 2.4-develop or any previous version
Usage of \Magento\Catalog\Block\Product\ListProduct::getProductPrice
in app/code/Magento/Catalog/view/frontend/templates/product/list.phtml
or product boxes in widgets affects listing performance.
It calculates price for products again even if the values received from collection.
On the screenshot you can see that product items have price values.
Then when a product is rendered, magento starts to resolve the price
It does these steps:
- Looks for price renderer
- loads linked products for composite products
- Resolve price type (it already available from collection)
Because the prices already available from the collection it's enough to render formatted price value (amount and currency) [e.g. 10.00 $]. But magento loads prices again does comparations and then renders it. Even when sort by price used.
Steps to reproduce (*)
- Render price box from the product collection on listing or search pages
- Use simple or composite products
- See that price boxes consumes a lot of time for price rendering by calling
\Magento\Catalog\Block\Product\ListProduct::getProductPrice
in the loop
Expected result (*)
- Prices are rendered faster
- Redundant loads and price comparations in
ListProduct::getProductPrice
are eliminated ListProduct::getProductPrice
just formats given price float values. It does not resolve prices again- Moreover it does not load linked/child products
Actual result (*)
- Prices are rendered slowly
ListProduct::getProductPrice
loads extra price data and performs comparationsListProduct::getProductPrice
does not use data already available from collection, loads prices againListProduct::getProductPrice
loads child/linked products and performs redundant price resolve.
Metadata
Metadata
Assignees
Labels
Issue recommended for the contribution dayGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentA defect with this priority could have functionality issues which are not to expectations.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchAffects critical data or functionality and forces users to employ a workaround.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it