0

I want to echo an attribute from a product on the productpage, but not exactly on view.phtml but in tabs.phtml which is loaded into view.phtml with getChildHtml.

In view.phtml I can use

echo $_product->getResource()->getAttribute('videotab')->getFrontend()->getValue($_product)

But when I do the same in tabs.html I get the following error:

Fatal error: Call to a member function getResource() on null in

How can I echo the product attribute there? I need to add the data inside a tab, so it needs to be loaded inside tabs.phtml

2

Try this

$productId = Mage::registry('current_product')->getId();
$_product = Mage::getModel('catalog/product')->load($productId);
echo $_product->getResource()->getAttribute('videotab')->getFrontend()->getValue($_product);
4
  • I still get: Fatal error: Call to a member function getResource() on null in – twan Oct 18 '17 at 9:59
  • try after clearing cache – Piyush Oct 18 '17 at 10:02
  • I cleared cache, but I tried this answer before and it didn't work. – twan Oct 18 '17 at 10:05
  • @twan check my updated answer – Piyush Oct 18 '17 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.