Magento: Get all attribute values (colors, sizes, etc..)

Magento get all the attribute values you have in the store. Get all the colors and sizes values in Magento. Change the attribute name to whatever you want values for, in the below script.

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color');
$colors = array();
foreach ($attribute->getSource()->getAllOptions(true) as $option) {
        $colors[] = $option['label'];
foreach($colors as $lbl) {
    echo "<span style='background-color:lightgrey'>".$lbl . "</span>";
        echo "<br>";

Replace color with any attribute you want to get values for. Above script also sorts the result set in alphabetic order to make it easy to view all values. If you don’t want to sort the values, just comment out the line which sorts it.

Leave a Reply