magento Complete Product Collection Filtering product collection

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


$model = Mage::getModel('catalog/product')->getCollection()

Filter based on store:


Filter based on product type:

$mode->addAttributeToFilter('type_id', 'configurable')
$mode->addAttributeToFilter('type_id', 'simple')

Filter based on status:


Filter using null and notnull:

$model->addAttributeToFilter('short_description', array('null' => true))
$model->addAttributeToFilter('short_description', array('notnull' => true))

Filter using greater than and less than:

$model->addAttributeToFilter('entity_id', array('gt' => 64230))
$model->addAttributeToFilter('entity_id', array('lt' => 64230))

Filter using greater than and equal to:

$model->addAttributeToFilter('entity_id', array('gteq' => 64230))

Filter using less than and equal to:

$model->addAttributeToFilter('entity_id', array('lteq' => 64230))

Filter using in and not in:

$model->addAttributeToFilter('entity_id', array('in' => array(1,4,64231)))
$model->addAttributeToFilter('entity_id', array('nin' => array(1,4,64231)))

Filter products by a range of entity id:

$model->addAttributeToFilter('entity_id', array(
             'from' => 64229,
             'to' => 64231

Filter based on product visibility:

$model->addAttributeToFilter('visibility', 4) //catalog,search
$model->addAttributeToFilter('visibility', 3) //catalog
$model->addAttributeToFilter('visibility', 2) //search
$model->addAttributeToFilter('visibility', 1) //not visible individually

Filter using like and not like:

$model->addAttributeToFilter('sku', array('nlike' => '5713%'))
$model->addAttributeToFilter('sku', array('like' => '%shirt%'))

Filter using equal to and not equal to:

$model->addAttributeToFilter('sku', array('neq' => 'shirt'))
$model->addAttributeToFilter('sku', array('eq' => 'shirt'))

Filter in stock products:

                'is_in_stock=1', //make this 0 for out of stock products

Set order by:


Set Page Size:


Got any magento Question?