Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fhferreira/3c7e137dd23792c94a70 to your computer and use it in GitHub Desktop.
Save fhferreira/3c7e137dd23792c94a70 to your computer and use it in GitHub Desktop.
<?php
require_once ("app/Mage.php");
umask(0);
Mage::app("default");
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
foreach ($collection as $customer) {
$customerObj = Mage::getModel('customer/customer')->load( $customer->getId() );
if ( ! $customerObj->getDefaultBillingAddress() ) {
foreach ($customerObj->getAddresses() as $address) {
$address->setIsDefaultBilling(true);
continue; // we only want to set first address of the customer as default billing address
}
}
if ( ! $customerObj->getDefaultShippingAddress() ) {
foreach ($customerObj->getAddresses() as $address) {
$address->setIsDefaultShipping(true);
continue; // we only want to set first address of the customer as default shipping address
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment