-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Review observer does load() on collection, which causes issues for other observers. #11910
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
Comments
Hi @Floddy, this issue is a duplicate of #10928. As I mentioned there, you should not use this event in the first place
some before_load of collection would be much more suitable. I do agree that Review observer is written poorly and pull request improving it would be much appreciated. However, there is no bug in current implementation.
|
I'll probably just use another event, not really sure what should be done if it should just be ran on this block explicitly, but that's another story. Regarding bug or not, it renders
Or is addAttribute to be deprecated? Agreed on afterGetLoadedProductCollection, I was too quick on that one. Can't find another public method to use a plugin for though. |
Hello @Floddy, I was working on event Which disables to filter anything in collection for other modules which using I was frustrated for almost a day why its not getting filter!!! Then for a check I disabled Magento_Review module. And guess what!!! It worked like charm! But its not the solution cause I use Reviews as well. So, The thing is if Magento has dispatched event @orlangur , Please take care of this if it's possible cause these small things makes developers more sick and wasting more time!! I am not commanding or anything ( cause I love Magento! ;) ) just frustrated a bit cause it was not developer's bug! :) |
@Sarvesh-A reported it into https://github.com/magento/community-features/. Feel free to fix it the right way :) |
@orlangur Thanks to reopen it! Appreciate that. :) |
Preconditions
Steps to reproduce
Alternatively:
Expected result
Actual result
Cause and solution
The cause of this is because:
Magento\Review\Observer\CatalogBlockProductCollectionBeforeToHtmlObserver.php uses the catalog_block_product_list_collection event, and does a $collection->load in the observer, which makes it not possible to use addAttributeToSelect afterwards.
Magento\Review should IMO instead use a plugin, that runs 'after' Magento\Catalog\Block\Product\ListProduct, which does the same thing as the observer - because what the functionality really needs to do, is to add the review data to the loaded collection:
There seems to be a similar plugin for the product compare list block, so I'm not sure why this isn't implemented in a similar way?
The text was updated successfully, but these errors were encountered: