I would like to get the product(Id)'s on a searchresult page in an observer which runs after the initial page render. But I can't seem to get it. The results are fetched by: \Mage_Catalog_Block_Product_List::_getProductCollection

But I don't know how to get that in an observer.
Does anybody know how to do that.

1 Answer 1


The current loaded product collection on category and searchresult pages can be accessed via


or, optionally


[EDIT] Preferred to use the registry.

That will return the appropriate model depending on the page you're on. Mage_Catalog_Model_Layer for catalog and Mage_CatalogSearch_Model_Layer for search

(Thanks for @janw for clearing that up)

  • Hi @sander, thanks for the quick reply. It doesn't work entirely. If I do Mage::getSingleton('catalog/layer')->getProductCollection()->getAllIds() It appears to return all id's almost all available products on the store.
    – janw
    Sep 7, 2015 at 12:08
  • What event are you using? Sep 7, 2015 at 12:10
  • No wait, the Mage::registry('current_layer')->getProductCollection()->getAllIds() does work. Both return different models. Mage_Catalog_Model_Layer vs Mage_CatalogSearch_Model_Layer
    – janw
    Sep 7, 2015 at 12:23
  • ah right. makes sense :) so it works? Sep 7, 2015 at 12:24
  • Yes it works. What also works is: Mage::getSingleton('catalogsearch/layer') If you could update your answer I'll accept
    – janw
    Sep 7, 2015 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.