May 2, 2013

magento: How to get the current login customer?

Get the customer session
$customer = Mage::getSingleton('customer/session')->getCustomer();

Get customer properties.
$customer->getId();
$customer->getEmail();
$customer->getName(); // Full name
$customer->getFirstName(); // First name
$customer->getLastName(); // Last name

You can also get other customer custom attribute, like nick_name
$customer->getNickName();


If you think you need to know the current admin user try this one.
Mage::getSingleton('admin/session')->getUser();

No comments: