Friday, 23 November 2018

How to get list billing address and list shipping address by customer id in magento 1.9

$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
    }
}

No comments:

Post a Comment