Reading list Switch to dark mode

    Magento Product Attributes

    Updated 21 March 2013

    Get Custom Attributes Value in Frontend.

    1. Suppose our custom attribute code is “test_attr” and of type Text Field or Text Area .

         $product = Mage::getModel("catalog/product")->load($product_id);
         echo $product->getTestAttr();

    I use getTestAttr() because my attribute code is “test_attr”, Use uppercase after underscore or begining of character, like

    for “testattr” method should be getTestattr()

    for “test_attr” method should be getTestAttr()

    Searching for an experienced
    Magento Company ?
    Find out More

    2. Suppose our custom attribute code is “test_attr” and of type Multiselect or Dropdown .

         $product = Mage::getModel("catalog/product")->load($product_id)
         $attributeCode = 'test_attr';
         $AllAttributes = $product->getAttributes();
            if(array_key_exists($attributeCode , $AllAttributes)){
                $Attribute = $AllAttributes["$attributeCode"];
                $Value = $Attribute->getFrontend()->getValue($product);
         echo $Value;

    3. To get all the options of attributes .

         $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','test_attr');
         $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
         $attributeOptions = $attribute->getSource()->getAllOptions();
         foreach($attributeOptions as $each){
           echo $each["label"]." ".$each["value"]."<br>";

    4. To get value of text type, attribute.


    5. To get values of multiselect type, attribute.


    6. To get value of dropdown type, attribute.


    Enjoy !!

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home