title: Magento 1.7 - order item joining with configurable product information
body: <p>I have a grid showing order items. I want to show product details for each item. But some are <code>simple</code> and some are <code>configurable</code>.</p>
  
  <p>Collection in the grid is <code>sales/order_item_collection</code>.</p>
  
  <p>In the <code>_prepareCollection()</code> I have these joins:</p>
  
  <pre><code>        $collection-&gt;getSelect()-&gt;join( 
             array('orders_alias' =&gt; $resource-&gt;getTableName('sales/order'))
             , 'main_table.order_id = orders_alias.entity_id'
             , array('orders_alias.increment_id', 'order_date' =&gt; 'orders_alias.created_at')
             , null);
  
      $collection-&gt;getSelect()-&gt;join( 
             array('p' =&gt; $resource-&gt;getTableName('catalog/product'))
             , 'main_table.product_id = p.entity_id
             , array('product_sku' =&gt; 'p.sku')
             , null); 
  </code></pre>
  
  <p>For an order item having a configurable product I see an extra row.<br>
  e.g. if someone buys a shirt in size XXL I see 2 rows for the order items. </p>
  
  <p>I guess I need to only show the visible products. How should I do this?</p>
  
  <p>If I go from an order and show the items I can do this:</p>
  
  <pre><code>    // get order items
      $items = $order-&gt;getAllVisibleItems();
  </code></pre>
  
  <p>But I need to check from an item to see if it is visible.</p>
  
  <p>Looking at <code>\app\code\core\Mage\Sales\Model\Order.php</code> I see:</p>
  
  <pre><code>    public function getAllVisibleItems()
  {
      $items = array();
      foreach ($this-&gt;getItemsCollection() as $item) {
          if (!$item-&gt;isDeleted() &amp;&amp; !$item-&gt;getParentItemId()) {
              $items[] =  $item;
          }
      }
      return $items;
  }
  </code></pre>
  
  <p>So If I add this filter:</p>
  
  <pre><code>$collection-&gt;addAttributeToFilter('parent_item_id', array('is' =&gt; new Zend_Db_Expr('null')));
  </code></pre>
  
  <p>it seems to show the correct order items. Is this the proper way?</p>