title: How to duplicate a customer address?
body: <p>When a customer enters an address for the first time than this address serves as billing <strong>and</strong> shipping address. But there is only one entry in the database. So if the customer later decides to alter the shipping address by editing the existing one than the billing address is changed too. To prevent this, I need two separate entries in the database, one for the billing address and one for the shipping address. Therefore, </p>
  
  <p>I wrote an event observer using the event <code>customer_address_save_after</code> to check if the entry for the default billing address is identical to the entry of the default shipping address. If so a copy of this address is saved serving as new shipping address. Well, at least this was the idea, </p>
  
  <pre><code>public function customerAddressSaveAfter($observer)
  {
      $session = Mage::getSingleton('customer/session');
  
      if ($session-&gt;getCustomer()-&gt;getDefaultBilling()  ==
          $session-&gt;getCustomer()-&gt;getDefaultShipping())
      {
          $address = $observer-&gt;getCustomerAddress();
  
          $address-&gt;unsAddressId()
                  -&gt;unsAddressType();           
  
          Mage::getModel('customer/address')
              -&gt;setData($address-&gt;getData())
              -&gt;setIsDefaultShipping('1')
              -&gt;setSaveInAddressBook('1')
              -&gt;save();
      }
  
      return $this;
  }
  </code></pre>
  
  <p>but running the code seems to result in an infinite loop until the memory is exhausted. What am I doing wrong?</p>