2

Could someone teach me how to retrieve the option label for current store view? There is a table eav_attribute_option_value where these information are already stored, but I don't know what model I must use.

2

Step1: First get the attribute id, for example by attibute code from the eav/entity_attribute model:

$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $YourattributeCode)

Step2: Using the attribute id, load the catalog/entity_attribute attribute model:

$attribute = Mage::getModel('catalog/product')
                ->getResource()
                ->getAttribute($attributeModel->getId());

Step3: set the current store id:

    $attribute
            ->setStoreId(Mage::app()->getStore()->getId());

Step4: get the option value:

/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
if ($attribute) :
$options = array();
if ($attribute->usesSource()) {
    foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) {
        if (is_array($optionValue)) {
            $options[] = $optionValue;
        } else {
            $options[] = array(
                'value' => $optionId,
                'label' => $optionValue
            );
        }
    }
}
endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.