Get an array of billing addresses and shipping addresses in Magento

Jun 21, 2013, by admin

Magento has no built in function to get an array of all shipping or billing addresses. However, you can do this by creating such an array by grabbing the address collection. Something likes this

  1. $all_data = array();
  2. $customer = Mage::getModel(‘customer/session’)->getCustomer();
  3. foreach($customer->getAddressesCollection() as $customer_address)
  4. {
  5. $all_data[] = $customer_address;
  6. }
  7. var_dump($all_data);