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 due to loading product collection twice #233

Open
Swahjak opened this issue Dec 16, 2024 · 1 comment
Open

Performance due to loading product collection twice #233

Swahjak opened this issue Dec 16, 2024 · 1 comment

Comments

@Swahjak
Copy link
Contributor

Swahjak commented Dec 16, 2024

Issue Brief

The product collection is being loaded twice due to calling getItems() early to check results.

Environment

  • PHP Version: 8.1
  • Magento Version: not relevant
  • Tweakwise Version: 8.2.0
  • Tweakwise Export Version: not relevant
  • Magento Deploy Mode: production|development
  • Third party modules:

Steps to reproduce

  1. Load Tweakwise product collection

Actual result

The load method is called twice due to the collection being cleared in Model/Catalog/Layer/ItemCollectionProvider.php:99 which causes all related event listeners (catalog_product_collection_load_after) and plugins being fired twice. Resulting in a performance hit.

Expected result

When loading a collection the load method should only be fired once to prevent unnecessary overhead.

@Swahjak
Copy link
Contributor Author

Swahjak commented Dec 16, 2024

In general I wonder what this https://github.com/EmicoEcommerce/Magento2Tweakwise/blob/master/Model/Catalog/Layer/ItemCollectionProvider.php#L99-L105 section actually does. Since the getSize() is also being overwritten by Tweakwise and triggers a load that isn't an option either. Would it be sufficient to have https://github.com/EmicoEcommerce/Magento2Tweakwise/blob/master/Model/Catalog/Product/AbstractCollection.php#L20 as a public and count those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant