Get customer name in Magento

24.Dec.2010

When creating a Magento theme, one has to worry about all aspects. Some of the most important things when creating a theme is personalization. In order to personalize your website for a current user, you can do various things, but most important one is knowing your clients name.

So, in order to get customer name in Magento, use following snippet:

1
2
3
4
5
6
$session = Mage::getSingleton('customer/session');
 
if($session->isLoggedIn()) {
   $customer = $session->getCustomer();
   echo $customer->getName();
}