Please, can someone tell me, how to get list shipping addresses and billing addresses the specific customer by customer id in Magento 1.9?
Thanks.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityPlease, can someone tell me, how to get list shipping addresses and billing addresses the specific customer by customer id in Magento 1.9?
Thanks.
Try following way:
$customerId = 2;
$customer = Mage::getModel('customer/customer')->load($customerId);
$defaultBilling = $customer->getDefaultBilling();
$defaultShipping = $customer->getDefaultShipping();
$allAddress = Mage::getModel('customer/address')->getCollection()->setCustomerFilter($customer);
foreach ($allAddress as $address) {
if($defaultBilling == $address->getId()) {
// its customer default billing address
} else if($defaultShipping == $address->getId()) {
// its customer default shipping address
} else {
// its customer other address that saved
}
}
please use the below code:
$customer = Mage::getModel('customer/customer')->load($customerId);
$defaultBilling = $customer->getDefaultBillingAddress();
$defaultShipping = $customer->getDefaultShippingAddress();
I had solved my problem,
this is my code, to get all address based customer id :
$customer_id = 1; //example
$customerdata = Mage::getModel('customer/customer')->load($customer_id);
foreach ($customerdata->getAddresses() as $address)
{
$addr = $address->toArray();
echo $addr['street'];
echo $addr['telephone'];
//....
}
Thank you for all