How to load Total Address collection of customer in magento
16,704
Have you tried doing it this way?
$customer = Mage::getSingleton('customer/session')->getCustomer();
foreach ($customer->getAddresses() as $address) {
Zend_Debug::dump($address->debug());
}
Author by
Elamurugan
Magento Certified + Web and API Developer with PHPStack, MEAN stack
Updated on June 05, 2022Comments
-
Elamurugan almost 2 years
I want to load the customer address collection in a custom script.
This code loads only billing address, but I need to load all the addresses(I have 3 addresses under this customer)
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); if ($customerAddressId){ $address = Mage::getModel('customer/address')->load($customerAddressId); // echo "<pre>"; print_r($address->getData());echo "</pre>"; Zend_Debug::dump($address->debug()); $street = $address->getData('street'); }
Tried this but this is not returning the shipping address.
Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
Please help me to load all the addresses from Magento customer table for particular user.
-
Elamurugan over 13 yearsgetAddressCollection returns array of records with entity_id, dates only. Not address collection , I want to load all the address for the particular user
-
clockworkgeek over 13 yearsMy mistake. The method should have been
getAddresses()
-
Elamurugan over 13 yearsWow, yes its loading all the addresses. But i dont understand why its loading address array multiple times with in foreach. Even i had only 3.
-
Elamurugan over 13 yearsAm sorry its my mistake. Its loading all the addresses correctly. Thanks @clockworkgeek