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.

1 Answer 1

     * @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();

    //here is another method
    $options = Mage::getResourceModel('eav/entity_attribute_option_collection');
    $values  = $options->setAttributeFilter($attribute->getId())->setStoreFilter($storeId)->toOptionArray();
  • And how to save it to 1 certain storeview?
    – snh_nl
    May 21, 2019 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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