I am trying to get custom attribute value in frontend
I am trying below code in view.phtml , its working fine.
when i used the same code in other .phtml file its giving error :
Fatal error: Call to a member function getId() on a non-object in
<?php
$product_id = Mage::registry('current_product')->getId();
$_product=Mage::getModel('catalog/product')->load($product_id);
$attribute = $_product->getResource()->getAttribute('cod_available');
if ($attribute)
{
echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}
?>
Mage::registry('current_product')
is not work out side the view.phtml file.if($_product->getData('cod_available')) { echo 'available'; }
this will be your condition.