title: Exporting Magento Orders - Getting Discount Amount
body: <p>I have custom PHP code shown below that exports orders in Magento.  I need this code to be able to get the total discount of the order as well as the amount of items in the order.  Can someone please help me with this?</p>
  
  <pre><code>// !    ----- GET NEW ORDERS -----
  $myOrder=Mage::getModel('sales/order'); 
  $orders=Mage::getModel('sales/mysql4_order_collection');
  
  //Optional filters you might want to use - more available operations in method _getConditionSql      in Varien_Data_Collection_Db. 
  $orders-&gt;addFieldToFilter('total_paid',Array('gt'=&gt;0)); //Amount paid larger than 0
  $orders-&gt;addFieldToFilter('status',Array('eq'=&gt;"processing"));  //Status is "processing"
  
  $allIds=$orders-&gt;getAllIds();
  foreach($allIds as $thisId) {
  $myOrder-&gt;reset()-&gt;load($thisId);
  
  
  //Getting Order Fields
  echo "'" . $myOrder-&gt;getBillingAddress()-&gt;getLastname() . "',";
  echo "'" . $myOrder-&gt;getTotal_paid() . "',";
  echo "'" . $myOrder-&gt;getShippingAddress()-&gt;getTelephone() . "',";
  echo "'" . $myOrder-&gt;getPayment()-&gt;getCc_type() . "',";
  echo "'" . $myOrder-&gt;getStatus() . "',";
  echo "\r\n";
  }
  </code></pre>