Gilberto Albino
Gilberto Albino

Reputation: 2745

How to solve Magento 1.7 Fatal error: Call to a member function toHtml() on a non-object Message

I'm running accross a situation here.

As far as I know, in previous versions of Magento, if one got this PHP fatal error message:

Fatal error: Call to a member function toHtml() on a non-object in C:\xampp\htdocs\magento\app\design\frontend\base\default\template\wishlist\view.phtml on line 50

You should do a simple change in page.xml file, so that :

<block type="core/profiler" output="toHtml"/>

would become:

<block type="core/profiler" output="toHtml" name="core_profiler"/>

But now... running Magento 1.7 this solution doesn't seem to work anymore!

Anybody has a solution for that?

Thanks in advance!

Upvotes: 0

Views: 13415

Answers (2)

Drew Hunter
Drew Hunter

Reputation: 10114

This is a perfect example of why people should use local.xml for base theme layout overrides!

The problem is that when working with your previous verison of Magento, at some point you copied over wishlist.xml from the base theme to your custom theme and not the wishlist template files.

There were some new blocks added to the the wishlist layout between version 1.6 and 1.7.

Line 50 of wishlist/view.phtml is trying to call toHtml on a child block named control_buttons...

<?php echo $this->getChild('control_buttons')->toHtml();?>

This block was only introduced in 1.7, so the wishlist.xml file you have from a previous version does not declare that block - hence the error " Call to a member function toHtml() on a non-object"

So, to resolve this you need to try and merge the 1.7 base wishlist.xml file with your customized verion - essentially adding in the new blocks declared in 1.7.

1.6 wishlist.xml here

1.7 wishlist.xml here

Upvotes: 7

ceckoslab
ceckoslab

Reputation: 1189

It's obvious, that your problem is not related with, the xml layout directive, that you've mentioned:

<block type="core/profiler" output="toHtml" name="core_profiler"/>

The fatal error is fired on line 50 in file app\design\frontend\base\default\template\wishlist\view.phtml

I guess, that you have updated your magento installation recently.

Can you please do the next experiment:

  1. In your active theme temporary rename layout/wishlist.xml to layout/wishlist-back.xml
  2. Clean up Magento cache
  3. Try to reproduce the problem again
  4. Share with us the result

Upvotes: 3

Related Questions