magento2: Performance problem on listings and widgets with Price box
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.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 13
- Comments: 19 (9 by maintainers)
Commits related to this issue
- magento/magento2#26850: Performance problem on listings and widgets with Price box — committed to engcom-Kilo/magento2 by nmalevanec 4 years ago
- #26850 Adjusted configurable product price indexing to save all values based on available simple options — committed to Bartlomiejsz/magento2 by Bartlomiejsz 7 months ago
- #26850 Adjusted integration tests — committed to Bartlomiejsz/magento2 by Bartlomiejsz 7 months ago
- #26850 Adjusted integration tests — committed to Bartlomiejsz/magento2 by Bartlomiejsz 7 months ago
This one still valid today. Hope someone can take a look at it
I had also performance issue for configurable product which have almost 2000 simple products (Magento CE 2.4.4). For me the most slow was function
\Magento\InventoryConfigurableProduct\Plugin\Model\Product\Type\Configurable\IsSalableOptionPlugin::filterProducts
, so I just overridden it with follow code:still valid on 2.4.5. I think this issue should be upgraded to P1 priority.