Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Tag Archives: Product

Magento – Creating a Configurable Product

Magento – How to get a product attribute value?


I have created an extra attribute ‘enquiry_only’ in the back-end, this is how I can retrieve the attribute value in the product info template page:
\public_html\app\design\frontend\base\default\template\catalog\product\

$enquiry_only = Mage::getModel('catalog/product')
                            ->load($_product->getId())
                            ->getAttributeText('enquiry_only');

Alternatively we can use like:

$prod = Mage::getModel('catalog/product')->load($_product->getEntityId());
					$prod = $prod->getData(); 								
					$enquiry_only = 'No';		
					$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'enquiry_only');
					foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
						if ($option['value'] == $prod['enquiry_only'])
							$enquiry_only = $option['label'];
					}