title: Pulling Item SKUs from Magento Sales/Orders Model?
body: <p>Im working on a script that is supposed to run at end of each night. It is supposed to look up how many of specific products (by SKU preferably) were sold that day and tally them up. There is a second part to this process but for now I'd be content with just echoing out the correct value. Im getting confused with how I should do this. Here is what I have so far:</p>
  
  <pre><code>require_once('../app/Mage.php');
  ini_set("error_reporting",E_ALL);
  ini_set("display_errors",true);
  umask(0);
  
  Mage::app('admin');
  
  // Some sort of SKU counter variable
  $sku_counter = 0;
  
  // Create order collection object
  $collection = Mage::getModel('sales/order')-&gt;getCollection();
  
  // Apply date filter. This would be 1 day in production but using this range as a test.
  $collection-&gt;addFieldToFilter(
   'created_at', 
   array('from' =&gt; '2012-05-01', 'to' =&gt; '2012-05-09')
  );
  
  // Iterate it for displaying results
  foreach ($collection as $order) {
  
      // This is where I fall apart. I know I need to either get all items or only get
      // items with the specific SKU. After that I need to get the quantity sold of that SKU
      // and add it to my $sku_counter. 
  
     echo 'There were " . $sku_counter . "sales of SKU XX-XXXX yesterday.";
  
  }
  </code></pre>
  
  <p>Any help is appreciated!</p>