Friday, 22 January 2016

Get Product attributes Value in Magento

 <?php
//call on any page and any place
 $attribute_code ="139";
echo $attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
 ?>


//On Catalog Page

<?php $_product = $this->getProduct(); ?>

<?php echo $_product->getData('attributename'); ?>


//On List page
To display a product manufactures attribute on the product list page

Go Admin -> Catalog -> Attributes -> Manage Attributes

Set "Used in Product Listing" to Yes

Then in 'list.phtml'

 <?php echo $_product->getAttributeText('manufacturer') ?>

Get Custom attribute value by name

<?php  echo $attributeValue = Mage::getModel('catalog/product')
      ->load($_product->getId())
      ->getAttributeText('attributename');
       ?>

1 comment: