1

I want to hide products, which don't have value of a particular attribute, from every page of my website. for this I have used observer on event catalog_product_collection_load_after and catalog_product_load_after and here is my observer function:

public function customFilter(Varien_Event_Observer $observer)
{
    $collection = $observer->getEvent()->getCollection();
    $collection->addAttributeToFilter('seller', array('neq' => 'NULL'));

    return $collection;
}

If I print the sql query and run it into my database it returns proper results. But the filter applied here does not reflect in frontend.

Is there any other way to do this?

1

I guess it's the wrong event you observe. In this place the collection is already loaded.

Replace:

catalog_product_collection_load_after

With:

catalog_product_collection_load_before
  • May be you are correct, question is old so can't check with your answer now . +1 for your efforts. – Piyush Jun 16 '17 at 10:15
  • If tested it recently ... it works ;) I'd be nice if you can reproduce this to close this question :) – sv3n Jun 16 '17 at 10:17
  • I will surely try this :) – Piyush Jun 16 '17 at 10:20

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.