Magento – How to Get Customer Address

addresscustomermagento-1.9

I have customer id .

Using customer id i want customer address.

so how to get customer address and using country id how to get full name of country

Best Answer

Thee address information is stored within the Mage_Customer_Model_Customer so you should be able to create an instance of it with the customer id.

$customer = Mage::getModel('customer/customer')->load($customerId);

Then depending on the type of address that you are looking for you should be able to call one of the following functions.

Primary Billing Address: $customer->getPrimaryBillingAddress();

Primary Shipping Address: $customer->getPrimaryShippingAddress();

General Address Selection: $customer->getAddressItemById();

As to the country information, by ID do you mean the ISO standard code for the country eg FR, GB etc in which case you could try:

$countryName = Mage::getModel('directory/country')->load('FR')->getName(); echo $countryName; // Should output France in this example

Magento Customer Model API Documentation: http://docs.magentocommerce.com/Mage_Customer/Mage_Customer_Model_Customer.html