Magento – How to load the product collection without some products

collection;magento-1.9productproduct-collection

Actually, I want to load the product collection except for some products. I have the product ids that I don't want in the collection. For example, the product ids that I don't want in the product collection is like

$productIds = array(10,20,30);

How can I do this?

Best Answer

You can use this code.

$productIds = array(10,20,30);
$collection = Mage::getModel('catalog/product')->getCollection()
            ->addFieldToFilter('entity_id', array('nin' => $productIds));