-
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 problem on listings and widgets with Price box #26850
Comments
Hi @ilnytskyi. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. @ilnytskyi do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Hi @engcom-Delta. Thank you for working on this issue.
|
✅ Confirmed by @engcom-Delta Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Isn't this because the product in question is a configurable product? |
@verheesj |
Hi @vishvesshah. Thank you for working on this issue.
|
Action items to fix:
Action items to testing:
|
This one still valid today. Hope someone can take a look at it |
Hope we'll have a fix for this in 2.4.5 ! Note : I see that @engcom-Kilo's commit deals only with configurable products. We have the same issue with grouped products. |
still valid on 2.4.5. |
Same here, prices are loaded separately for every product of the configuration. EDIT: if (!$this->salableResolver->isSalable($this->getSaleableItem())) { Also this line might be slow as it check sku manually for every product: foreach ($skus as $sku) {
$isSalable = $this->isProductSalable->execute($sku, $stockId);
$results[] = $this->isProductSalableResultFactory->create(
[
'sku' => $sku,
'stockId' => $stockId,
'isSalable' => $isSalable,
]
);
} isProductSalable calls composite stock resolvers in a loop which has major impact on the performance. |
I had also performance issue for configurable product which have almost 2000 simple products (Magento CE 2.4.4). --- vendor/magento/module-inventory-configurable-product/Plugin/Model/Product/Type/Configurable/IsSalableOptionPlugin.php
+++ vendor/magento/module-inventory-configurable-product/Plugin/Model/Product/Type/Configurable/IsSalableOptionPlugin.php
@@ -106,15 +106,24 @@
* @param array $isSalableResults
* @return void
*/
- private function filterProducts(array $products, array $isSalableResults) : void
+ private function filterProducts(array &$products, array $isSalableResults) : void
{
+ $isSalableResultsTest = [];
+ foreach ($isSalableResults as $result) {
+ if (!$result->isSalable()) {
+ $isSalableResultsTest[$result->getSku()] = $result->isSalable();
+ }
+ }
+
+ if (empty($isSalableResultsTest)) {
+ return;
+ }
+
foreach ($products as $key => $product) {
- foreach ($isSalableResults as $result) {
- if ($result->getSku() === $product->getSku() && !$result->isSalable()) {
- $product->setIsSalable(0);
- if (!$this->stockConfiguration->isShowOutOfStock()) {
- unset($products[$key]);
- }
+ if (array_key_exists($product->getSku(), $isSalableResultsTest)) {
+ $product->setIsSalable(0);
+ if (!$this->stockConfiguration->isShowOutOfStock()) {
+ unset($products[$key]);
}
}
} |
Exactly, MSI is querying every stock for every product. Another pain point is swatches renderer which loads all options for every configurable product on the listing. |
Latest version of M2 has the same issue. |
For google shopping we there upload each simple products of configured products with their prices and individual links to preselect the option, e.g. https........html?ps=MTU4PTIxOCYxNTk9MjIy#158=218&159=222 When loading the page, for the first second it displays the "as From" price from the lowest price of another simple product of the configurable product. Later (3 second?) it renders the correct price of the simple product together with its swatches. But that's too late for the google shopping crawler. He takes the first displayed "from price", which is incorrect. this leads to penalties at google and wrong ads. I looked into final_price.phtml files but it did not help. i believe the Magento_Catalog/js/price-box.js must be changed? Either to get rid of the display of the "from price" and/or how to speed up the display of the correct price? Magento ver. 2.4.4 |
…l values based on available simple options
Latest version of Magento Commerce. Performance cannot be this bad, this isn't acceptable. We're sadly looking at other platforms as a result. I really want to stick with Magento, but I honestly cannot make a good case for it when things like this always make it to production. |
@jlenzstaysafe try this module https://github.com/EcomDev/magento2-product-preloader |
@ilnytskyi @jlenzstaysafe this module is just a one part, it still requires to create a custom module and optimization of SQL queries. But yes, using it you drop PLP page to under 700ms load time |
Preconditions (*)
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:
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 (*)
\Magento\Catalog\Block\Product\ListProduct::getProductPrice
in the loopExpected result (*)
ListProduct::getProductPrice
are eliminatedListProduct::getProductPrice
just formats given price float values. It does not resolve prices againActual result (*)
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.The text was updated successfully, but these errors were encountered: