Magento

Get list of product attribute in Magento

# Get list of colors from Magento Installation

Let’s create a file called getcolors.php on Magento root folder.

require_once ( “app/Mage.php” );
umask(0);
Mage::app(“default”);
Mage::getSingleton(“core/session”, array(“name” => “frontend”));
$attribute = Mage::getSingleton(‘eav/config’)->getAttribute(‘catalog_product’, ‘color’);
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
}
print_r($options);

When you excute the file getcolors.php either from shell or browser, It will print the list of color used in product catalog.

You Might Also Like