I am trying to load attribute options for specific store only. It's a multistore setup and options for attribute are entered for Admin column as well as for individual stores. However, no options are entered for some stores. I want to get values for stores and get 0 or nothing if a store has no values entered. Don't want to get Admin column values in this case.

The code I have used is below:

$attributeOptions = Mage::getResourceModel('eav/entity_attribute_option_collection')

This still returns admin column values. I understand this is to support multilingual but there must be a way to get this.

  • Might be caching issue if you write this kind of code in your phtml then it will cache by magento and it will give you wrong result Commented Sep 7, 2016 at 13:29
  • @MurtuzaZabuawala Thanks for your response. I have tried by clearing cache but same results.
    – F-Z
    Commented Sep 8, 2016 at 4:25

2 Answers 2


The function below will check for the existence of any attribute option for the attribute ID and store IDs that you specify.

 * @param int $attributeId
 * @param int|array $storeId
 * @return bool
function attributeHasStoreOptions($attributeId, $storeId)
    $resource = Mage::getSingleton('core/resource');
    $adapter  = $resource->getConnection('core_read');

    $select = $adapter->select()->from(array('option_table' => $resource->getTableName('eav/attribute_option')), 'COUNT(*)');
    $select->where('option_table.attribute_id = ?', $attributeId);
        array('value_table' => $resource->getTableName('eav/attribute_option_value')),
        "option_table.option_id = value_table.option_id");
    $select->where('value_table.store_id IN(?)', $storeId);
    return (bool)$adapter->fetchOne($select);

// i picked these values arbitrarily, change to suit your needs
$attributeId = 92;
$storeId     = 1;

if(attributeHasStoreOptions($attributeId, $storeId)) {
  • Thanks for the answer. Direct SQL queries are the way to go in this case. You code worked perfectly, I have modified it slightly to get actual rows for the passed store.
    – F-Z
    Commented Sep 8, 2016 at 4:58
  • Happy to help! Please don't forget to mark the answer as accepted and good luck! Commented Sep 8, 2016 at 4:59
$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();
  • Your code is similar to mine. This works but it returns admin (store 0) values if some or all values for specific store are missing. Direct SQL query works fine in this case.
    – F-Z
    Commented Sep 8, 2016 at 5:00

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.