I have added a column "rescue_order_name" in sales_order table. Now i want to display the values of this column in the admin panel, sales, order grid and give the option to the admin to filter certain record on the basis of this field

I have been able to display the column in the sales grid

<columns name="sales_order_columns">
    <column name="rescue_order_name" class="\Rescuechimp\OrderManager\Ui\Component\Listing\Column\Ordername">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">text</item> 
                <item name="sortable" xsi:type="boolean">false</item>
                <item name="label" xsi:type="string" translate="true">Order Name</item>

and in my Class

 public function prepareDataSource(array $dataSource) {
    if (isset($dataSource['data']['items'])) {
        foreach ($dataSource['data']['items'] as & $item) {
            $order = $this->_orderRepository->get($item["entity_id"]);
            $rescueName = $order->getData("rescue_order_name");
            $item['rescue_order_name'] = $rescueName;

    return $dataSource;

I am able to get the correct values, but at the moment, i am unable to use the filters for this property.

enter image description here

No matter what i type in this Order Name field, my result remain the same and nothing gets filtered.

I do not want to add this column in the sales_order_grid table.

1 Answer 1


You need to join your new field rescue_order_name to order grid collection first.

First override Magento\Sales\Model\ResourceModel\Order\Grid\Collection and add below function to join.

protected function _initSelect()

            ['so' => $this->getTable('sales_order')],
            'main_table.entity_id = so.entity_id',

        return $this;

And you can remove class="\Rescuechimp\OrderManager\Ui\Component\Listing\Column\Ordername" from sales grid xml for your rescue_order_name column.

I hope this might help you it works fine to me.

Let me know if you need any more help.

  • Please accept answer if it helped you so others can take reference from this. Feb 16, 2018 at 8:59
  • i did exactly this and was able to display the values. However, i have run into another issue, When i apply a filter on Purchase Point (store_id),, it gives me ambiguity error as the field "store_id" exist in both sales_order and sales_order grid table. I have tried mapping the field, but that does not work as well Feb 16, 2018 at 12:09
  • @SarveshAhuja ! lets suppost if we don't add attribute in sales_order table and then try to filter then ? actually i face this issue . I have custom column in sales order grid thats value return from Ui\Column\Listing\CustomerAttribute.php it work but not apply filter . how can apply filter Even no column of any table exist in database mean without joining ? let me know if you have solution pelase :)Thanks
    – HaFiz Umer
    Sep 30, 2019 at 11:03

Your Answer

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

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