Magento – Get Products list with all product attributes in Magento

collection;magento-1.9productproduct-attributeproduct-collection

I have a statement

$collection = Mage::getResourceModel('catalog/product_collection');

in file app/code/core/Mage/Catalog/Block/Product/New.php in protected function _getProductCollection().

It gives me list of common attributes when I check by

print_r($collection->getData()); 

Here I need additional attribute value for attribute 'color'

Some products contain attribute color and some not. When I use the statement $collection->addAttributeToSelect('color', 'color'); it gives me only product with attribute color

I need all products + products with attribute color

please help me.

Best Answer

To get product collection with all attributes use this:

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');

Whereas to get all products having attribute color only use

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('color','color');