I have a situation and I'm not sure what the best solution is.

In the user accounts (customers) I've added a single field that gives a list of all the manufacturers. The admin can select a set of manufacturers per customer.

When a customer logs in on the frontend, he should only be able to see the product of the manufacturers that are selected.

I was thinking of rewriting some pieces of the product model, but I'm not sure what would be the best location, any tips?

  • 1
    Rewrite your product collection model, you just need to add one more filter i.e. your custom attribute to filter the product collection. Jul 30, 2013 at 18:06

1 Answer 1


There are a few ways of doing this. Personally I would suggest listening to the event catalog_product_collection_load_before. This can be done with the following section of config.xml


Then in your observer you should be able to add the filters that you need with something like the following.

public function catalogProductCollectionLoadBefore(Varien_Event_Observer $observer) {
    /** @var Mage_Catalog_Model_Resource_Product_Collection $collection */
    $collection = $observer->getCollection();
    $collection->addAttributeToFilter('attribute_code', array('in' => array(5,6)));

    // If you log your select then you can double check that the correct sql is being formed
    mage::log((string) $collection->getSelect());

Obviously you can remove the mage::log once you have the correct filters on your collection.

  • As a paranoid check, add an observer for product model loads as well on catalog_product_load_before.
    – benmarks
    Feb 24, 2014 at 20:54

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.