I need to filter collection for product listing. I know how to re-write block. But i want to filter that collection by observer.

basically i want to do this by observer...

this the code for filter blank image.

->addAttributeToFilter('image', 'no_selection');

You can read how to use observers in the official wiki - http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method .

For your case please try to use this:
in config.xml


in Observer.php

public function filterBlankImage(Varien_Event_Observer $observer)
    $collection = $observer->getEvent()->getCollection();
    $collection->addAttributeToFilter('image', 'no_selection');
    return $this;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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