0

This is my code:

$collection = Mage::getModel('customer/customer')->getCollection();
foreach ($collection as $customer){
          $defaultBilling     = $customer->getDefaultBillingAddress();
          $defaultBilling2   = $customer->getPrimaryBillingAddress();
          $defaultShipping    = $customer->getDefaultShippingAddress();
}

In all of the 3 cases I'm getting false or null. The all idea is that i want to check which customers has a default billing address and doesn't have a default shipping address or vice versa.

1

You should try with customer address model Mage_Customer_Model_Address:

$collection = Mage::getModel('customer/address')->getCollection();
//var_dump((string)$collection->getSelect());
foreach ($collection as $address){
    /** @var Mage_Customer_Model_Address $address */
    $customer = $address->getCustomer();
    $defaultBilling     = $customer->getDefaultBillingAddress();
    $defaultShipping    = $customer->getDefaultShippingAddress();

}

See more here: How to Check If given address is Default Shipping or Billing address using Address id Magento

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.