如何获取客户自定义属性值

mpr*_*ype 6 php magento

当我运行以下两行代码时,我返回值161.现在,如果我深入研究customer_eav,我看到161与attribute_id477相关,然后如果我进一步挖掘customer_entity_varchar我找到一行field['attribute_id']=477并且值为USD.如何使用magento的模型/方法获取此属性字符串值...

$customer = $session->getCustomer();
$attributes = $customer->getDefaultCurrency(); // returns 161... not USD
Run Code Online (Sandbox Code Playgroud)

ben*_*rks 17

echo $customer->getResource()
              ->getAttribute('default_currency')
              ->getFrontend()
              ->getValue($customer);
Run Code Online (Sandbox Code Playgroud)

  • 由于涉及的对象数量相当大,这是一种时髦的语法. (2认同)