this is normal. The block corresponding to the template app/design/frontend/default/modern/template/page/html/header.phtml is located in app/code/Core/Page/Block/Html/Header.php .
If you read the block code, you will see that there is no "getCustomer ()" function. And when you try to call $this->getCustomer()->getName(); on the template page, since the getCustomer () function does not exist, it returns nothing.
As a result, you try to call "getName ()" nothing ... and an error message appears: Fatal error: Call to a member function getFirstname() on a non-object .
As you can read: Calling the member function getFirstname () on a non-object .
If you want to get the client name in header.phtml, you should:
$session = Mage::getSingleton('customer/session'); if($session->isLoggedIn()) { $customer = $session->getCustomer(); echo $customer->getName(); echo $customer->getFirstname(); }
Hyuug.
source share