Magento – Magento 2 : How to Customise Admin Sales Order Grid Collection

admingridmagento-2.1.3sales-order

I am trying to customise admin sale order grid collection.
I have created an custom sale_order attribute store_manager. These store managers are admin users eg: 'manager1', 'manager2'.

1) Orders are manually assigned to 'manager1' or 'manager2' — this part is done

2) Now I am trying to set filter on sale order grid collection, so when manager logged in to there system they can only see there orders.

In Magento 1 we have sales_order_grid_collection_load_before, sales_order_grid_collection_load_after for this requirement .

Is tried to such event for Magento 2 but didn't get any success.

My Queries :

Is there any such event like (sales_order_grid_collection_load_after) in magento 1 which full fill my requirement?

Is there any other way where I can set filter to sale order grid collection?

Note : I already search for this on google but didn't get any perfect solution.

Best Answer

override with your module Mage_Sales by writing in module.xml smth like

<module name="----" setup_version="1.0.0">
    <sequence>
        <module name="Magento_Sales"/>
    </sequence>
</module>

Create in your module view/adminhtml/ui_component/sales_order_grid.xml

in sales_order_grid do smth like

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
    <column name="attribute_id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">Attribute Name</item>
                <item name="sortOrder" xsi:type="string">3</item>
            </item>
        </argument>
    </column>
</columns>

Related Topic