I want to display all the products which belongs to a particular manufacturer.
Here is my code:-
$manufacturerId = 2;
$attributeCode = 'manufacturer';
$products=Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter($attributeCode, $manufacturerId);
echo $products->getItems();
It displays nothing. How can I get this??
Best Answer
Instead of
$products->getItems();
try looping through the collection.But I suggest adding some attributes to the collection. You might get only the id and sku (and a few other uninteresting attribute values) the way you are doing it.