1- Following code load product useing ids.


$productIds = array(5, 22, 45, 75, 88);
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$_productCOllection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('entity_id', array('in' => $productIds))
->addAttributeToSelect($attributes);// $attributes or '*'

2- For collection within a range


$_productCOllection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('entity_id', array(
'from' => $startPrOID,
'to' => $EndPrOID
))
->load();

3- Following code load product useing SKUs.


$productSku = array('1111', '1112', '1113', 'HTC Touch Diamond', 'microsoftnatural');
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('sku', array('in' => $productSku))
->addAttributeToSelect($attributes);

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *