Search code examples
magentoentity-attribute-value

Magento: Getting the Value of an EAV Attribute Option/Select


I Have an object of Mage_Customer_Model_Customer and ran the following code:

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

I am trying to get the eav_attribute_option_value.value of those option_id's which is the word "Male" or the word "Female"

I am not sure how to do this and spent quite a bit of time debugging the account form select widget with no success. I am also curious on how you figured this out.

Thanks in advance

Sincerly, Tired Dev


Solution

  • $attributeOptions = $customer->getSource()->getAllOptions(false);
    echo "<pre>"; print_r($attributeOptions); echo "</pre>";
    

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

    EDIT: From Link:

    $entityType = Mage::getModel('eav/config')->getEntityType('invoice');
    $entityTypeId = $entityType->getEntityTypeId();
    
    $attribute = Mage::getResourceModel('eav/entity_attribute_collection')
                    ->setCodeFilter('order_id')
                    ->setEntityTypeFilter($entityTypeId)
                    ->getFirstItem();