I am trying to get a list of products that have a sale price that are only in certain categories. Right now I am trying to use a product collection to get this data. I am not sure how I would go about restricting the collection for particular categories only. Here is what I have so far:
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('special_price', array('neq' => ""))
->addAttributeToFilter('discontinued', array('neq' => 1))
->setPageSize(10)
->setOrder('price', 'ASC')
;
The discontinued attribute is a custom attribute that we use so that products don't display but also don't 404.
Is there a way to use the product model and restrict to certain categories?