I'm trying to modify items in a collection on page load (catalog) and using the event: catalog_product_collection_load_after
and the code for the event is :
$observer->getCollection()
->addFieldToFilter('entity_id', array('nin' => array_keys($_excludeProducts)))
->clear()
->load();
this does exclude product(s) but the count is wrong. like there're 5 products in the collection and on the grid as well but the count is 6 items. How can i correct this?
getSize()
and I'm not too sure aboutcount()
so it makes sense. A solution I don't have for you at this momentload_after
? Even if Magento is smart enough to not go into endless recursion, why don't you useload_before
to add the field to filter?load_before
load()
in the observer, which you should not and need not thenload()
and usingload_before
in event didn't help either.