Magento 1.9 – Identify the Right Collection in catalog_product_collection_load_after

event-observermagento-1.9product-collectionproduct-list

I want to do some processing on the products list (the products shown when browsing categories etc) before they are rendered.

I tried using the catalog_product_collection_load_after event, but its called on any products collection used, which include things like recently viewed items, related items, etc. and I only want to react on the time its called for the actual main products list.

I tried to filter the events by checking things like block type/name, controller name, page category etc, but they all proved to be insufficient to distinguish between the event on the main product list and other spam.

so my question:

  1. how can I edit the products list before they are shown via events (eg without editing Magento core code / temlates)?
  2. if your answer is "observe the catalog_product_collection_load_after event": how do I know which of the many product collections loaded is the main products grid?

thanks!

Best Answer

You can use the event catalog_block_product_list_collection.
This one is dispatched in the product list block.

Related Topic