Skip to content

DO NOT do load() of product collection in Review observer as it causes issues for other observers #57

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
orlangur opened this issue Jun 12, 2018 · 8 comments

Comments

@orlangur
Copy link
Contributor

Issues:
magento/magento2#10928
magento/magento2#11910

Poor attempts to fix:
magento/magento2#8485
magento/magento2#12770

CollectionLoader does not make any sense from domain perspective. Observer needs to be reworked to use other event/be a plugin. Please try to not break BC as others may fix this undesired behavior on their side with some ugly hacks.

@orlangur
Copy link
Contributor Author

Cc: @dvynograd you may be interested in getting this done.

@dvynograd
Copy link

Sounds interesting, I will try to finish it, say next week. Didn't think it still actual.

@orlangur
Copy link
Contributor Author

@dvynograd Magento Contribution Day is coming next week in Kiev 👍 Not sure if it is distributed this time or not.

@apasare
Copy link

apasare commented Nov 23, 2018

this might sound silly, but why are we not introducing a new event like this:

    $this->_eventManager->dispatch(
        'catalog_block_product_list_collection',
        ['collection' => $collection]
    );
    $collection->load();
    $this->_eventManager->dispatch(
        'catalog_block_product_list_collection_loaded',
        ['collection' => $collection]
    );

and move the CatalogBlockProductCollectionBeforeToHtmlObserver observer to catalog_block_product_list_collection_loaded event?

@orlangur
Copy link
Contributor Author

orlangur commented Dec 1, 2018

@godvsdeity how is that different from converting CatalogBlockProductCollectionBeforeToHtmlObserver to a afterLoad plugin for collection?

@apasare
Copy link

apasare commented Dec 1, 2018

@orlangur i was thinking that maybe the context matters, and you will want to keep that. catalog_block_product_list_collection gives a more granular context than afterLoad which is fired every time the collection is loaded, right?

@orlangur
Copy link
Contributor Author

orlangur commented Dec 3, 2018

@godvsdeity yes, it fires each time, so we should be careful.

Adding a random event in a random place in code is no better than some https://github.com/magento/magento2/pull/12770/files#diff-6d08440fa49b7b33f7d87b9da7ec863f - introducing entity which does not make sense from business logic perspective.

Why we have many places where collection is loaded? Maybe we should refactor that?

@orlangur
Copy link
Contributor Author

orlangur commented Jun 1, 2019

Yay, @Den4ik did it 💪

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

3 participants