How to fix ‘Fatal error: Call to a member function toHtml() on a non-object’ in Magento?

Sometimes, after a theme installation or a upgrade you can face the following error message in your Magento web site:

Fatal error: Call to a member function toHtml() on a non-object in app/code/core/Mage/Core/Model/Layout.php on line 529

In order to resolve the issue, open the app/design/frontend/default/YOUR_THEME/layout/page.xml file and change the following line:

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

to

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

Replace the YOUR_THEME string with the exact name of the Magento theme which you want to use.

Then navigate to your Magento admin area->System->Cache Management and flush your script's cache. Alternatively, you can follow the instructions from the How to clear the cache in Magento article.

Once you are ready, reload your web site.

You need help with a shopping cart? SiteGround is specialized in eCommerce hosting and provides expert support for a large number of shopping carts. Check out our shopping cart hosting services!