0

I'm trying to add a new column to orders grid; shipping_description in sales_order table, i can use instead, shipping_information in sales_order_grid (main table). Here is my code

protected function _renderFiltersBefore()
{
    $joinTable = $this->getTable('sales_order');
    $joinTable_track = $this->getTable('sales_shipment_track');
    $this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['shipping_description']);
    $this->getSelect()->joinLeft($joinTable_track, 'main_table.entity_id = sales_shipment_track.order_id', ['track_number']);
    parent::_renderFiltersBefore();
}

Is it possible to use shipping_information from sales_order_grid table without making a join? Cause i'm getting this error

Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous, query was: SELECT COUNT(*) FROM `sales_order_grid` AS `main_table`

I added this function

protected function _initSelect()  {

  $this->addFilterToMap('increment_id', 'main_table.increment_id');
  $this->addFilterToMap('status', 'main_table.status');
  parent::_initSelect();
  return $this; 

}

This fixed the issue but i don't like to add filter to map to all the fields.

Your Answer

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

Browse other questions tagged or ask your own question.