Engine23
blogBannerImage
By Engine23

Magento - How to get product collection ( 2 ways )

Version #1 use a simple array

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter('sku', array('n2610','bb8100'));


$items = $collection->getItems();
echo count($collection);

Version #2 use a more specific array

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

$collection->addAttributeToFilter(
array(
array('attribute'=>'sku','eq'=>"n2610"),
array('attribute'=>'sku','eq'=>"bb8100")
));

$items = $collection->getItems();
echo count($collection);