title: Convert magento admin quote into a multi address order
body: <p>Say I have a quote from the admin create order with all the products already entered, how could I go about writing some code to add multiple shipping addresses and assign the item to the address. </p>
  
  <p>Ive got some code working, based loosely off the frontend multiship model. The problem I'm having  is adding the multiple address and assigning the items to the quote. If I have a standard quote, how can I add the multiple addresses?</p>
  
  <p>I've already tried :</p>
  
  <pre><code> $address = Mage::getModel('customer/address')-&gt;load($addressID);
   $quote-&gt;addShippingAddress($address);
  </code></pre>
  
  <p>Which seems to only hold one address</p>
  
  <p>The whole function:</p>
  
  <pre><code> public function createMultiOrders() {
      // print_r($_POST);
      $items = $_POST['item'];
      $itemsByAddress = array();
      $billingInfo = array();
      $session = Mage::getSingleton('adminhtml/session_quote');
          $quote = $session-&gt;getQuote();
  
          //first we are reorganizing the data provided by javascript into an array based on address ID's
          foreach ($items as $key =&gt; $item) {
              $addID = $item['addressID'];
              $itemID = $key;
              $qty = $item['qty'];
              $itemsByAddress[$addID][] = array('itemID' =&gt; $itemID, 'qty' =&gt; $qty);
          }
          // print_r($itemsByAddress);
          //now that we have an array of items, seperated by which addressid they goto, we can create the order for each address
  
          foreach ($itemsByAddress as $addressID =&gt; $items) {
              $address = Mage::getModel('customer/address')-&gt;load($addressID); 
              $quote-&gt;addShippingAddress($address);
              echo"&lt;br/&gt;address id is $addressID, items are: &lt;br/&gt;"; 
              foreach ($items as $item) {
                  // $address-&gt;addItem($_item);
                  ///add items to order
                  //  echo"id before is $item&lt;br/&gt;";
                  $itemID = explode('-_', $item['itemID']);
                  $itemID = $itemID[0];
                  $qty = $item['qty'];
                  echo "itemid is $itemID, qty is " . $qty . " &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;";
              }
          }
          //print_r(get_class_methods($quote));
          $shippingAddresses = $quote-&gt;getAllShippingAddresses();
          try {
              foreach ($shippingAddresses as $address) { 
                  $order = $this-&gt;_prepareOrder($address);
  
                  $orders[] = $order;
                  Mage::dispatchEvent(
                          'checkout_type_multishipping_create_orders_single', array('order' =&gt; $order, 'address' =&gt; $address)
                  );
              }
  
              foreach ($orders as $order) {
                  $order-&gt;place();
                  $order-&gt;save();
                  if ($order-&gt;getCanSendNewEmailFlag()) {
                      $order-&gt;sendNewOrderEmail();
                  }
                  $orderIds[$order-&gt;getId()] = $order-&gt;getIncrementId();
              }
  
              Mage::getSingleton('core/session')-&gt;setOrderIds($orderIds);
              Mage::getSingleton('checkout/session')-&gt;setLastQuoteId($quote-&gt;getId());
  
              $quote-&gt;setIsActive(false)-&gt;save();
  
              Mage::dispatchEvent('checkout_submit_all_after', array('orders' =&gt; $orders, 'quote' =&gt; $quote));
  
              return $this;
          } catch (Exception $e) {
              Mage::dispatchEvent('checkout_multishipping_refund_all', array('orders' =&gt; $orders));
              throw $e;
          }
  </code></pre>