-1

How can solve Fatal error Call to a member function setTitle() on a non-object in magento

Fatal error: Call to a member function setTitle() on a non-object in app/code/core/Mage/Customer/Block/Form/Login.php on line 40
1

2 Answers 2

1

The problem here is that your head block is missing from the layout.

Here the code causing the issue:

$this->getLayout()->getBlock('head')->setTitle(Mage::helper('customer')->__('Customer Login'));

But as the head block is missing, it cannot set the title to the page.

To find out how is that happening, you need to find out where is the head getting removed.

It can be removed via layout XML like:

<remove name="head"/>

Or directly via PHP:

$this->getLayout()->unsetBlock('head');

To help you find out how it is getting removed, find the page where this error is getting trigerred to narrow the possibilities of locations where the head is removed.

0

Message error tells you a lot - you are calling method setTitle() on something which is not a object. The simplest thing you can do is try to debug something what you trying set title on. If you are trying for example setTitle() on some product use Zend_Debug::dump($product) - if your Block is correctly added to view you will see dump on front. It will tell you if it is an array, object or anything else. It higly possibly that your $product->setTitle() is an array or string for example.

If you cannot see dump you can try log it using in you Block Mage::log($product, null, 'mylog.log');. After that it sholud appear custom log mylog.log and inside you can see a dump of this thing you are trying to set title on.

And what about results of dump? It almost sure that under your variable in code there is no object. Maybe it is an array, string or int. If you want use magic method setTitle on it you have to change code before to get an object, but without any code I cannot help any more, just general thoughts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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