I'm writing some magenta 1.9 codes for set existing customer address to set as default billing and shipping address

<?php $customerId = Mage::getSingleton('customer/session')->getCustomer();
$customer = Mage::getModel('customer/customer')->load($customerId->getId()); 
$data = array();

foreach ($customer->getAddresses() as $address){

$data = $address->toArray();
  if(trim($data['postcode']) !=''){

But it doesn't seems works, anyone have idea to fix this please, Thank You

1 Answer 1


Try this code :

if(trim($data['postcode']) !='')
    $customerAddress = Mage::getModel('customer/address');
    $customerAddress->load(trim($data['id']); //ID means address Id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.