Magento: Get User Details

  • Avinash
  • 2
  • Apr 23, 2013
  • Tips & Tricks

In this quick tip we will see how we can get details of logged in customer in Magento.

You can use below code snippet in any model, controller or phtml file.

Get Magento User Details

// Retrieve Session Object $session = Mage::getSingleton('customer/session'); // Check if user is logged in or not. if($session->isLoggedIn()) { $customer = $session->getCustomer(); // Get Customer ID echo $customer->getID(); // Get Customer Name echo $customer->getName(); }
// Retrieve Session Object
$session = Mage::getSingleton('customer/session');

// Check if user is logged in or not.
if($session->isLoggedIn())
{
   $customer = $session->getCustomer();
   
   // Get Customer ID
   echo $customer->getID();

   // Get Customer Name
   echo $customer->getName();
   
}

Let me know if there is any room for improvement in above code snippet.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by:

  • Cathlyn

    You saved my lots of hours!!!!! thanks for sharing.!!!!!

  • http://www.biztechconsultancy.com/magento-development.htm Magento Development

    Finally, I got the answer. My searching ended here from your post. Thanks Avinash. You solved my problem.