I am trying to retrieve all options for all store views for a single attribute e.g. color.

For the attribute color I have created two options blue and white. I have tried the following code that is suppose to return all the options labels for all store views, but only returns the admin option label for me.

$option_arr = array();
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color');
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
  $option_arr[$option['value']] = $option['label'];
}
// $option_arr contains Array([4] => Blue, [3] => White)

The following works fine for getting all the attribute color titles for each store view, but does not work for options.

$product = Mage::getModel('catalog/product')->load();
$attribute_title = $product->getResource()->getAttribute('color');
// $attribute_title contains Array([1] => ~~~, [2] =>Color, [3] => Couleur, [4] => Còôlòôr)

Screenshot of my color attribute and options.

up vote 14 down vote accepted
    /**
     * @var $config  Mage_Eav_Model_Config
     * @var $options Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection
     */
    $storeId   = 3;
    $config    = Mage::getModel('eav/config');
    $attribute = $config->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'color');
    $values    = $attribute->setStoreId($storeId)->getSource()->getAllOptions();
    print_r($values);

    //here is another method
    $options = Mage::getResourceModel('eav/entity_attribute_option_collection');
    $values  = $options->setAttributeFilter($attribute->getId())->setStoreFilter($storeId)->toOptionArray();
    print_r($values);

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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