Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 454
Bryan Ruiz Avatar asked Jul 12 '11 03:07

Bryan Ruiz


People also ask

How can I get the the attribute label from the attribute value in Magento 2?

Place the below code at a place whereever you want to display the attribute label. $_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product); Just replace your_attribute_code with whatever your attribute is named. Save this answer.


1 Answers

$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();
like image 97
B00MER Avatar answered Oct 14 '22 16:10

B00MER