Magento 1.8 – How to Remove Product from Collection by Custom Product Attribute

magento-1.8

Friends,
Facing the problem while filtering the product collection.
I have get my product collection.

$collection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToSelect('*');

and for every product i have custom attribute called product_creator_id [code].

So I need to filter the product based on the product_creator_id.

I am Using following code to get, but Its not affecting the list

$collection->addAttributeToFilter('product_creator_id', array('in' => $productCreatorIds));

Any suggestion for this

Best Answer

If you use an 'in' filter, you will need to provide an array:

$productCreatorIdsToFilter = array(1,2,3);
$collection->addAttributeToFilter('product_creator_id', array('in' => $productCreatorIdsToFilter));