0

Getting Error in admin Configuration after clearing Browser Cache & History. I am getting the below error on refresh.

Fatal error: Call to a member function getUsername() on a non-object in /var/www/app/design/adminhtml/default/default/template/page/header.phtml on line 33

Below is my file code on line number 33

<?php echo $this->__("Logged in as %s", $this->escapeHtml($this->getUser()->getUsername())) ?><span class="separator">|</span><?php echo $this->formatDate(null, 'full') ?><span class="separator">|</span><a href="<?php echo $this->getLogoutLink() ?>" class="link-logout"><?php echo $this->__('Log Out') ?></a>
1
  • 1
    This means there is no active admin login but for some reason redirection to the login form failed. Try the following: Clear cookies, open https://yourdomain/index.php/admin/index/login and log in again. Aug 21, 2015 at 10:08

2 Answers 2

1

Looks like you don't have any method name Username in $this->getUser() .

First do one thing try to see the all method and variables in $this->getUser() using var_dump method. And then search for user.

Hope that will help you to debug your problem.

-1

This is really cleared that there is an error in header.phtml on line number 33, See what is getUsername() function there, or send me the header.phtml content.

getUsername() on a non-object in /var/www/app/design/adminhtml/default/default/template/page/header.phtml`on line 33

getUsername() is not an recognized function because this is not define in header.php So here is the way you can retrieve customer information in header.phtml file.

$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
   $customerdata = $session->getCustomer();
  $uname =  $customerdata->geUsername();
} 
else {$uname = ''; }

Add above lines of code & replace your line of code with below line

__("Logged in as %s", $this->escapeHtml($uname)) ?>|formatDate(null, 'full') ?>|getLogoutLink() ?>" class="link-logout">__('Log Out') ?>

1
  • Hi Amit , I edited my Question please find the default code
    – Magento AJ
    Apr 1, 2015 at 10:44

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.