Skip to content

Performance problem on listings and widgets with Price box #26850

Open
@ilnytskyi

Description

@ilnytskyi

Preconditions (*)

  1. 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.
Selection_047

Then when a product is rendered, magento starts to resolve the price
Selection_048

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 (*)

  1. Render price box from the product collection on listing or search pages
  2. Use simple or composite products
  3. 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 (*)

  1. Prices are rendered faster
  2. Redundant loads and price comparations in ListProduct::getProductPrice are eliminated
  3. ListProduct::getProductPrice just formats given price float values. It does not resolve prices again
  4. Moreover it does not load linked/child products

Actual result (*)

  1. Prices are rendered slowly
  2. ListProduct::getProductPrice loads extra price data and performs comparations
  3. ListProduct::getProductPrice does not use data already available from collection, loads prices again
  4. ListProduct::getProductPrice loads child/linked products and performs redundant price resolve.

Metadata

Metadata

Assignees

Labels

Area: PricingArea: ProductCDIssue recommended for the contribution dayComponent: CatalogComponent: PricingEvent: Global-Contribution-DayIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S1Affects critical data or functionality and forces users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions