Try the Demo

Magento Forum

   
In tabs.phtml $this->getProduct(); doesnt return object
 
janose
Jr. Member
 
Total Posts:  2
Joined:  2010-05-08
 

Hello,

i have a really weird problem in magento 1.6. I’m trying to fix the tabs on the product description page.
I have the following error:

Fatal error: Call to a member function getData() on a non-object in ... tabs.phtml

What i tried so far.

Product displays in the view.phtml template file. View.phtml calls $this->getChildHtml(’info_tabs’).
Now…

In view.phtml $this->getProduct(); returns an object with details regarding the selected product BUT
in tabs.phtml $this->getProduct(); does not. That is why i get the Fatal error.

When i replace
$_product = Mage::getModel(’catalog/product’)->load($_myproduct->getData(’entity_id’));
with
$_product = Mage::getModel(’catalog/product’)->load(117);
it works, but of course it needs to get the id of the selected product.

Anybody faced this issue?
Btw products were imported and not manually added, but it shouldn’t make a difference since in view.phtml i gets the product object.

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
nguyentrongtiep
Jr. Member
 
Total Posts:  4
Joined:  2012-05-02
 

<?php
$_product = Mage::registry('product');
$productId = $_product->getId();
?>

It’s work for me. Hope helpful for you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
magentodesignin
Jr. Member
 
Total Posts:  29
Joined:  2012-08-26
 

Hi use this code in tabs.phtml file

if(Mage::registry(’current_product’)){
$_product = Mage::getModel(’catalog/product’)->load(Mage::registry(’current_product’)->getId());
}

After using this you will get data for product same as it retrives in view.phtml

 Signature 

Hire Magento Developer from Krish Inc – Magento Solutions Partner

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top