2012-02-26 31 views
5

Tôi có dữ liệu sau đây trong eav_attribute_option_value của cài đặt Magento 1.4.0.1.Magento: lớp để truy xuất dữ liệu từ 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 

Tôi có dữ liệu của option_id trong var, giả sử $ delivery (ví dụ = 6). Tôi muốn lấy dữ liệu bằng cách sử dụng một lớp Magento hiện có. Vì vậy, dữ liệu đầu ra phải là "Levertijd 4 tot 10 werkdagen".

Có ai biết nếu có một chức năng hiện có trong Magento mà tôi có thể sử dụng cho việc này không?

Xin cảm ơn trước.

Trả lời

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

Bạn có thể tải trực tiếp các attribute_option_value thực thể với $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(); 

Sau đó truy cập vào giá trị của nó

$eav_attribute_option_value->getValue() 
Các vấn đề liên quan