Magento:获得EAV属性选项/选择的价值

Bry*_*uiz 7 magento entity-attribute-value

我有一个Mage_Customer_Model_Customer的对象并运行以下代码:

$customer->loadByEmail($customer->getEmail());
$customer->getGender();  //returns the EAV attribute option_id's of 1 or 2
Run Code Online (Sandbox Code Playgroud)

我想获取那些option_id的eav_attribute_option_value.value,即"男性"或"女性"这个词

我不知道如何做到这一点并花了相当多的时间调试帐户表单选择小部件没有成功.我也很好奇你是怎么想出来的.

提前致谢

真诚的,累了的开发

B00*_*MER 9

$attributeOptions = $customer->getSource()->getAllOptions(false);
echo "<pre>"; print_r($attributeOptions); echo "</pre>";
Run Code Online (Sandbox Code Playgroud)

http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/

编辑:来自链接:

$entityType = Mage::getModel('eav/config')->getEntityType('invoice');
$entityTypeId = $entityType->getEntityTypeId();

$attribute = Mage::getResourceModel('eav/entity_attribute_collection')
                ->setCodeFilter('order_id')
                ->setEntityTypeFilter($entityTypeId)
                ->getFirstItem();
Run Code Online (Sandbox Code Playgroud)

  • 我正在寻找所选的选项,这个链接就是这样提供的.谢谢! (2认同)