Skip to content
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 of isSalable method check on configurable product #26065

Closed
ilnytskyi opened this issue Dec 16, 2019 · 2 comments
Closed

Performance of isSalable method check on configurable product #26065

ilnytskyi opened this issue Dec 16, 2019 · 2 comments
Assignees
Labels
Component: ConfigurableProduct Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@ilnytskyi
Copy link
Contributor

ilnytskyi commented Dec 16, 2019

Magneto 2.3.x

Preconditions (*)

  1. Render product listing

Proposal to optimize or replace getUsedProductCollection in call
\Magento\ConfigurableProduct\Model\Product\Type\Configurable::isSalable since it can affect performance
e.g. create alias for getUsedProductCollection -> getLinkedProductCollection and use this method in isSalable additionally store its result to prevent multiple DB calls.

Steps to reproduce (*)

  1. Render prices on product listing
  2. Check if product is saleable

Expected result (*)

  1. plugin \Magento\Swatches\Model\Plugin\Configurable::afterGetUsedProductCollection is not called after isSaleable call
  2. \Magento\ConfigurableProduct\Model\Product\Type\Configurable::isSalable stores result since it can be called twice

Actual result (*)

  1. plugin \Magento\Swatches\Model\Plugin\Configurable::afterGetUsedProductCollection is called when isSaleable checks
  2. Multiple call of \Magento\ConfigurableProduct\Model\Product\Type\Configurable::isSalable affects performance since the result is not cached and afterGetUsedProductCollection called
@ilnytskyi ilnytskyi added Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: ConfigurableProduct labels Dec 16, 2019
@m2-assistant
Copy link

m2-assistant bot commented Dec 16, 2019

Hi @ilnytskyi. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 16, 2019
ilnytskyi added a commit to ilnytskyi/magento2 that referenced this issue Dec 16, 2019
@ghost ghost assigned ilnytskyi Dec 16, 2019
@ihor-sviziev ihor-sviziev removed the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Dec 18, 2019
ilnytskyi added a commit to ilnytskyi/magento2 that referenced this issue Jan 22, 2020
@ilnytskyi ilnytskyi changed the title Performance of \Magento\ConfigurableProduct\Model\Product\Type\Configurable::isSalable Performance of isSalable method check on configurable product Jan 22, 2020
@slavvka
Copy link
Member

slavvka commented Feb 7, 2020

Hi @ilnytskyi. Thank you for your report.
The issue has been fixed in #26071 by @ilnytskyi in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

@slavvka slavvka added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Feb 7, 2020
@slavvka slavvka closed this as completed Feb 7, 2020
magento-engcom-team added a commit that referenced this issue Feb 7, 2020
…able products #26071

 - Merge Pull Request #26071 from ilnytskyi/magento2:isSaleable-26065
 - Merged commits:
   1. ad5c3e4
   2. 87842d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ConfigurableProduct Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

4 participants