Attribute

Magento dropdown attributes

Let's say you want to create a new attribute for a product, e.g. 'color'.
There should be a set of possible values for this attribute. So what you do is create
an attribute of 'Dropdown' type. You set all its properties, give it a title and create its options, e.g. 'black', 'white', 'red' and 'yellow'.
But there is still one surprise that you may have. When you try to obtain the color simply by:

$product->getColor()

all you get is a numeric value corresponding to an option value in the dropdown.
But you probably would like to get a color name.
Fortunately you don't need to construct database queries, as Magento already thought about it.
So to get the name of the color selected for a product you need to use a method:
$product->getAttributeText('color');

where 'color' is the text that you have set as attribute code. Remember that you cannot
change attribute code nor its type after you create it.