<?php

/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Custom\Sales\Model\ResourceModel\Order\Grid;

use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;

/**

 * Order grid extended collection
 */
class Collection extends OriginalCollection {

    protected function _initSelect() {
        $this->addFilterToMap('pname', 'sales_order_item.sku');
        $this->addFilterToMap('user_id', 'sales_order.user_id');
        $this->addFilterToMap('status', 'main_table.status');
        $this->addFilterToMap('warehouse_id', 'main_table.warehouse_id');
        $this->addFilterToMap('customer_id', 'main_table.customer_id');
        $this->addFilterToMap('increment_id', 'main_table.increment_id');
        $this->addFilterToMap('base_grand_total', 'main_table.base_grand_total');
        $this->addFilterToMap('grand_total', 'main_table.grand_total');
        $this->addFilterToMap('store_id', 'main_table.store_id');
        parent::_initSelect();

        $this->getSelect()->joinLeft(
                ['sales_order_item' => $this->getTable('sales_order_item')], //2nd table name by which you want to join mail table
                'main_table.entity_id = sales_order_item.order_id',
                ['CONCAT(sales_order_item.name,"(",sales_order_item.sku,")") as pname']
        );
        $this->getSelect()->joinLeft(
                ['sales_order' => $this->getTable('sales_order')],
                'main_table.entity_id = sales_order.entity_id', ['user_id']
        )->group('main_table.entity_id');
    }

}