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.
[cc lang=”php”]
// 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();
}
[/cc]
Let me know if there is any room for improvement in above code snippet.
You saved my lots of hours!!!!! thanks for sharing.!!!!!
Finally, I got the answer. My searching ended here from your post. Thanks Avinash. You solved my problem.