Skip to content

Module Review observer executes ->load() on products collection #10928

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

Closed
lbajsarowicz opened this issue Sep 17, 2017 · 3 comments
Closed

Module Review observer executes ->load() on products collection #10928

lbajsarowicz opened this issue Sep 17, 2017 · 3 comments
Assignees
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@lbajsarowicz
Copy link
Contributor

Preconditions

  1. Magento 2.1.7
  2. PHP 7.0.22
  3. Module Review enabled

Steps to reproduce

Problem occured when tried to inject own filters into products collection.

  1. Build own Observer that runs on
    catalog_block_product_list_collection event
  2. Try to use
    $productCollection = $observer->getEvent()->getCollection();
  3. Then try execute
    $productCollection->addAttributeToFilter('entity_id', ['in' => $fancyIds]);

Expected result

  1. Products collection should be filtered to provided IDs
  2. Products collection should not be loaded too early

Actual result

  1. Exception message saying that Collection is already loaded

Temporary workaround

I disabled Review observer:

<!-- Disabled because of ->load() bug on product collection in Review module -->
<observer name="review" disabled="true" />
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Sep 17, 2017
@orlangur
Copy link
Contributor

Please clarify what exactly you call a bug here and approximate approach how would you fix it.

Build own Observer that runs on catalog_block_product_list_collection event

Does not look like an appropriate event is used here, some before_load of product collection seems to be a better choice.

@magento-engcom-team
Copy link
Contributor

@lbajsarowicz we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@PivitParkour94
Copy link

So what's the solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests

4 participants