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.
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()
// 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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With