Search This Blog

Jun 13, 2012

Magento: Fixing Fatal Error: Call to a member function loadByUsername on a non Object

It is a common error in magento when we are trying to call a method which does not exist on the object that we call. Even though the obvious reason is that the function does not exist, there are some instances that we need to look for some other reasons why this error occurs.

I bumped with this kind of situation when are transferring magento installation from one server to another. All the configurations were changed and cache were deleted and so on. The front end of the site looks good but when we are trying to login in admin panel, we got this error "Fixing Fatal Error: Call to a member function loadByUsername on a non Object". I'm sure that we didn’t touch anything on the admin side, so what nightmare causing this error?.

As a sort of solution I installed new magento store and with that I compare both site admin files to determine if there are missing files on the site that we transferred. Luckily, I found out that there is one file that missing. The config.xml under the app\code\core\Mage\Admin\etc. I copy the file, paste it on the site that we transferred and it solve our problem.

Important: Please make sure though that both magento (sites) have the same version to avoid further conflict.

Hope it helps.


Ole said...

Maybe you can help.
Last night I edited the file app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php
When I try to go the the admin login page I get this error "Fatal error: Call to a member function loadLatestNotice() on a non-object in /home/xxxxxx/public_html/shop/app/code/core/Mage/AdminNotification/Helper/Data.php on line 75"

I changed the inbox.php file back to its original form, but I'm still getting the error. I've tried manually deleting the cache and sessions, but the error keeps persisting.
I do not have SSH access and I'm not sure what to do next.

I'm going crazy. Please help.

Janzell Jurilla said...

Hi Ole,

You are trying to call a method function that doesn't exist. What version of magento you are using?

Try to comment out the line that causing the error and try. I guess loadLatestNotice is not really important.