I have to add a custom where clause to the query that retrieve data to fill sales order in the relative admin grid.
I know that it is defined here \vendor\magento\module-sales\etc\di.xml
as virtualType
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">sales_order_grid</argument>
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order</argument>
</arguments>
</virtualType>
and \vendor\magento\framework\View\Element\UiComponent\DataProvider\DataProvider.php
is used to retrieve data, but where and how could i use _initSelect()
or _renderFiltersBefore()
discussed here How to join order grid collection to custom table in Magento2? to change query?
In magento 1 i did it with the filter_condition_callback
option for addColumn()
in customized grid file.
SELECT main_table.* FROM sales_order_grid AS main_table
, i have to change it toSELECT main_table.* FROM sales_order_grid AS main_table WHERE .........