Having a option value for an attribute I would like to get the code/id associated to this option value.
How can I get this ?
Sql/Magento model approach are both wellcome
EDIT: I can retrieve option label for an attribute of a configurable product in this way:
function getRawAttribute($product, $attributeId)
{
$attributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
foreach ($attributes as $attr)
if ($attr['attribute_id'] == $attributeId) {
foreach ($attr['values'] as $option)
$rawAttr[$option['value_index']] = $option['label'];
}
return $rawAttr;
}
What is missed here for me is the possibility to get the label for a particular store view.
I'm going to evaluate info form this link:
http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/