- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Observer to alter collection product collection
I've seen we're able to alter the rendering of the result in the product collection thanks to the event
catalog_block_product_list_collection
I need it (I think) to show only product for a group of users.
My questions are :
1. What does exactly an event (or observer ?) do ?
2. How to use it in order to alter the result of the product collection in the front store ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Observer to alter collection product collection
1. What does exactly an event (or observer ?) do ?
- RE : In a simple term i would say , when you would like to do your custom actions on before or after the magento's native functionality even you can use event observer , let's say you would like to show a popup when customer is successfully logged in into the system then you can create observer on the event customer_login and then write the code for your popup.
Refer this link for more details - https://devdocs.magento.com/guides/v2.2/extension-dev-guide/events-and-observers.html
2. How to use it in order to alter the result of the product collection in the front store ?
- here i would like to give working example link , refer this - https://magento.stackexchange.com/questions/114207/unable-to-update-product-collection-via-observer-...
Hope it helps !