Get product collections by some range of ids in magento

By | April 25, 2014
1
2
3
4
5
6
7
8
9
10
11
<?php

$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('entity_id', array('from' => $startId,'to' => $endId))->addFieldToFilter('status', 1)->addAttributeToSelect(array('name','sku','entity_id','special_price','price','status','visibility','updated_at','created_at','popularity','actual_stock_available','setting_type','average_clarity','carat_weight'));

foreach ($collection as $product) 
{ 
    echo $i.') '.$product->getData('entity_id');echo"\n";
    $i++;
}

?>

Leave a Reply