2012-02-26 60 views
5

我在Magento 1.4.0.1安裝的eav_attribute_option_value中有以下數據。Magento:從eav_attribute_option_value檢索數據的類

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 

我有一個var的option_id數據,比如$ delivery(example = 6)。我想通過使用現有的Magento類來檢索數據。所以輸出數據應該是「Levertijd 4 tot 10 werkdagen」。

有沒有人知道是否有一個現有的Magento功能,我可以使用它?

在此先感謝。

回答

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(); 
    } 
} 
6

您可以直接加載attribute_option_value實體$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(); 

然後訪問它的值

$eav_attribute_option_value->getValue()