I need to exclude a category from my productCollection but I dont know how to achieve this.
Requirements:
- Only visible products
- Ordered by: created_at DESC
- Exclude category id 43
- Limit 4 (products)
To retrieve my collection I use the following code:
$collection = Mage::getResourceModel('catalog/product_collection')
->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)
->addAttributeToSort('created_at', 'DESC')
->setPageSize(4)
->setCurPage(1);
This works fine, but I can't add this filter:
->addFieldToFilter('category_id', array('nin' => array('43')))
I found these similar questions, but they wont solve my problem.
How to exclude a category from a magento getCollection
Magento - How do I exclude a category from product collection?