10

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

18

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

  • Mage::getModel('directory/country')->load('FR') this is not working.. – ND17 Apr 21 '15 at 11:07
  • @ND17 I have updated the example for the country with a little more detail on the process. Hope that helps you. – John Cuthbert Apr 21 '15 at 15:22
  • How to apply this into magento 2? – Joey Apr 9 '18 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.