I want to show the customer ip in the sales order grid in admin section.

protected function _prepareCollection()

    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->join('sales_flat_order', 'main_table.entity_id = sales_flat_order_grid.entity_id',array('remote_ip') );
    return parent::_prepareCollection();

But its returns:-

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sales_flat_order_grid.entity_id' in 'on clause', query was: SELECT main_table.*, sales_flat_order.remote_ip FROM sales_flat_order_grid AS main_table INNER JOIN sales_flat_order ON main_table.entity_id = sales_flat_order_grid.entity_id


You can use below code

$collection->getSelect()->join('sales_flat_order', 'sales_flat_order.entity_id = main_table.entity_id',array('remote_ip') );

  • It's not worked for me. – Vivek Sharma Jan 29 at 8:57
  • It solved the error what you mentioned. So are you still getting error or not showing ip in grid? – Varun Parmar Jan 29 at 10:18
  • Have you checked? It works? – Varun Parmar Feb 5 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.