title: Magento - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
body: <p>I've change <strong>app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php</strong> to customize what's on the <strong>Orders</strong> grid.</p>
  
  <p>In <code>_getCollectionClass()</code> I have this:</p>
  
  <pre><code>protected function _getCollectionClass()
  {
      //return 'sales/order_grid_collection';
      return 'sales/order_collection';
  }
  </code></pre>
  
  <p>and in <code>_prepareCollection()</code> I have this:</p>
  
  <pre><code>protected function _prepareCollection()
  {
      $collection = Mage::getResourceModel($this-&gt;_getCollectionClass());
  
      $collection-&gt;getSelect()-&gt;joinLeft(array('s1' =&gt; 'sales_flat_order_address'),'main_table.shipping_address_id = s1.entity_id',array('region','firstname','lastname'));
      $collection-&gt;getSelect()-&gt;joinLeft(array('s2'=&gt;'sales_flat_order_address'),'main_table.billing_address_id = s2.entity_id',array('firstname','lastname'));
  
      $collection-&gt;getSelect()-&gt;columns(new Zend_Db_Expr("CONCAT(s2.firstname, ' ',s2.lastname) AS billing_name"));
      $collection-&gt;getSelect()-&gt;columns(new Zend_Db_Expr("CONCAT(s1.firstname, ' ',s1.lastname) AS shipping_name"));
  
  $collection-&gt;getSelect()-&gt;joinLeft(array('sfo'=&gt;'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email','sfo.weight','sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status','sfo.base_grand_total','sfo.grand_total')); // New 
      $collection-&gt;getSelect()-&gt;joinLeft(array('sfoa'=&gt;'sales_flat_order_address'),'main_table.entity_id = sfoa.parent_id AND sfoa.address_type="shipping"',array('sfoa.street','sfoa.city','sfoa.region','sfoa.postcode','sfoa.telephone')); // New
  
  
      $this-&gt;setCollection($collection);
  
      return parent::_prepareCollection();
  }
  </code></pre>
  
  <p>Now I've changed the <code>_prepareColumns()</code> to add my necessary fields and all works great! Except for one thing...</p>
  
  <p>When I search for orders by <strong>Billing</strong> or <strong>Shipping</strong>, I get an error. I've added <strong>filter_index</strong>'s (<code>'filter_index' =&gt; 'theindex'</code>) to all the necessary components and they all work great EXCEPT those two fields <strong>Billing</strong> or <strong>Shipping</strong>. </p>
  
  <p>So I put <strong>filter_index</strong>'s on those too.</p>
  
  <p>Everything comes up great. I can search the other fields but as soon as I search the <strong>Billing</strong> or <strong>Shipping</strong> fields, I get this error:</p>
  
  <pre><code>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
  </code></pre>
  
  <p>I have tried all sorts of things but nothing seems to work. Can someone please help!???</p>
  
  <hr>