Magento : How to get customer detail by customer Id

If customer is logged in on site and you want to get all information of that customer then you can get by below script:

if( $customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
    print_r($customerData);
}

It will show you result in an array format:

Array
(
    [entity_id] => 1
    [entity_type_id] => 1
    [attribute_set_id] => 0
    [website_id] => 1
    [email] => john.doe@example.com
    [group_id] => 1
    [increment_id] => 000000001
    [store_id] => 1
    [created_at] => 2011-02-27 11:03:11
    [updated_at] => 2011-02-27 11:03:11
    [is_active] => 1
    [firstname] => John
    [lastname] => Doe
    [password_hash] => 204948a4dfs0e4263438db22d5:eg
    [prefix] => 
    [middlename] => 
    [suffix] => 
    [taxvat] => 
    [default_billing] => 1
    [default_shipping] => 1
)

And finally you can print the detail like:

echo $customerData ['firstname'];
echo "
"; echo $customerData ['lastname']; echo "
"; echo $customerData ['email'];

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*