cancel
Showing results for 
Search instead for 
Did you mean: 

Observer to alter collection product collection

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 ?

1 REPLY 1

Re: Observer to alter collection product collection

Hi @morgan_tartreau1

 

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 !

if issue solved,Click Kudos & Accept as Solution