Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

magento get custom attribute label

I've a problem, I want to show the label of a custom attribute in the product page. I explain me better, starting from this link because is what I want to do: http://www.customy.com/blog/how-to-display-video-on-magento-product-page/

I want a video product in the sidebar of the product page, so I create a new custompage.phtml and i put this in the sidebar from catalog.xml, in my custompage.phtml I put this code to have the custom label:

getResource()->getAttribute('video')->getStoreLabel();?>

but I have this error:

"Fatal error: Call to a member function getResource() on a non-object in ..path//"

I have try different code but still have this problem. I think that I forget to put something in my .phtml but I'm new of Magento and I don't know what!

Thank in advance!

like image 616
valentina.a87 Avatar asked Mar 21 '23 20:03

valentina.a87


1 Answers

Since $_product didn't work then you'll need to load the object before attempting to access the attribute. Try this:

$product_id = Mage::registry('current_product')->getId();
$_product=Mage::getModel('catalog/product')->load($product_id);
echo $_product->getResource()->getAttribute('video')->getStoreLabel();
like image 140
seanbreeden Avatar answered Apr 08 '23 05:04

seanbreeden