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. – Qaisar Satti Dec 09 '15 at 07:00we gave attributes value as "yes", but its displaying "NO"
– Baby in Magento Dec 09 '15 at 07:02if($_product->getData('cod_available')) { echo 'available'; }this will be your condition. – Qaisar Satti Dec 09 '15 at 07:09echo '<pre>'; print_r($_product->getData());if($_product->getCodAvailable())) { echo 'available'; }– Qaisar Satti Dec 09 '15 at 07:24