2012-09-18 46 views
4

當我運行以下兩行代碼時,返回值爲161.現在,如果我通過customer_eav挖掘,我會看到161涉及attribute_id 477,然後如果我深入挖掘customer_entity_varchar我找到一行field['attribute_id']=477,價值是美元。我怎樣才能使用Magento的模型/方法這個屬性字符串值...如何獲得客戶自定義屬性值

$customer = $session->getCustomer(); 
$attributes = $customer->getDefaultCurrency(); // returns 161... not USD 
+1

我很抱歉,但...什麼? – Erik

+0

您可以創建客戶屬性,他們填充客戶的eav表...您可以使用magic methog getAttributeName()獲取客戶屬性,但它會返回一個外部ID代碼... – mprototype

回答

12
echo $customer->getResource() 
       ->getAttribute('default_currency') 
       ->getFrontend() 
       ->getValue($customer); 
+1

實際上哇哇哇哇哇哇哇哈哈的工作。太感謝了。我早些時候嘗試過,它失敗了,我必須有一個語法錯誤或者調用了一個時髦的方法。 – mprototype

+2

由於涉及相當大的對象數量,這是一種時髦的語法。 – benmarks