1

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

1 Answer 1

0

You can use below code

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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