The following code has done the trick for others but I'm not exactly sure how to implement this. I will really appreciate if anyone can assist me with this.
1. Call your collection and filter by the attributes you want to filter (all but the category one). For example:
[sourcecode language=”php”]
$collection= Mage::getResourceModel(‘catalog/product_collection’)
->addFieldToFilter(‘is_saleable’,1)
->addFieldToFilter(‘type_id’, array(‘eq’ => ‘configurable’));
[/sourcecode]
2. After doing this, you can apply your multiple category filter as follows:
[sourcecode language=”php”]$categories_to_filter = array(‘3’, ‘4’, ‘5’);
$ctf = array();
foreach ($categories_to_filter as $k => $cat) {
$ctf[][‘finset’] = $cat;
}
$collection->joinField(‘category_id’, ‘catalog/category_product’, ‘category_id’, ‘product_id = entity_id’, null, ‘left’)
->addAttributeToFilter(‘category_id’,array($ctf));
[/sourcecode]