We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
And the code beneath to the prepareColumns function:
$this->addColumn('state', array(
'header' => Mage::helper('sales')->__('Invoice Status'),
'index' => 'state',
'type' => 'options',
'options' => Mage::getResourceModel('sales/order_invoice_collection')->addAttributeToSelect('state'),
));
We got the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sales_flat_invoice.parent_id' in 'on clause'
What is going wrong?