5

I have the following data in eav_attribute_option_value of a Magento 1.4.0.1 installation.

value_id  |  option_id  |  store_id  |  value
-------------------------------------------------------------------------
35        |  7          |  0         |  Levertijd 1 tot 3 werkdagen
36        |  6          |  0         |  Levertijd 4 tot 10 werkdagen
37        |  5          |  0         |  Langer dan 11 werkdagen
38        |  4          |  0         |  Levertijd onbekend
39        |  3          |  0         |  Pre-Order

I have the data of option_id in a var, say $delivery (example = 6). I want to retrieve the data by using a existing class of Magento. So output data should be "Levertijd 4 tot 10 werkdagen".

Does anyone know if there is an existing function in Magento that I can use for this?

Thanks in advance.

2 Answers 2

6

You can directly load attribute_option_value entity with $option_id

$eav_attribute_option_value = Mage::getModel('eav/entity_attribute_option')
    ->getCollection()
    ->setStoreFilter()
    ->join('attribute', 'attribute.attribute_id=main_table.attribute_id', 'attribute_code')
    ->addFieldToFilter('main_table.option_id', array('eq' => $option_id))
    ->getFirstItem();

Then access to its value

$eav_attribute_option_value->getValue()
3
// Your variable
$option_id = 6;

// Retrieve values
$attributes = Mage::getModel('eav/entity_attribute_option')->getCollection()->setStoreFilter()->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code');
foreach ($attributes as $attribute) {
    if ($attribute->getOptionId()==$option_id) {
        echo $attribute->getValue();
    }
}

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.