Wednesday 21 December 2016

How to get customer details in frontend of magento

Many time we need customer data when we go through custom module.

Customer is saved in session so we can get customer data using following script.

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$data = Mage::getSingleton('customer/session')->getCustomer();
}

Or you can direct get customer id or customer name using of following script.

For First name :
Mage::getSingleton('customer/session')->getCustomer()->getData('firstname');

For customer id :
Mage::getSingleton('customer/session')->getCustomer()->getId();

If you have any query then feel free to contact me at Jainish Senjaliya

No comments:

Post a Comment