While i am using same code for filter it's working but i have break other grid like customer,invoice,cms page and get error "Not registered handle cms_page_listing_data_source"
While i have moved di.xml file in etc/ folder grid filter not working. any have idea about.
I have created di.xml file in etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
FIlter collection in
<?php
namespace Vendor\Module\Model\ResourceModel\Order\Grid;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
class Collection extends OriginalCollection {
protected $_authSession;
public function __construct(
EntityFactory $entityFactory,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
\Magento\Backend\Model\Auth\Session $authSession
) {
$this->_authSession = $authSession;
parent::__construct($entityFactory, $fetchStrategy, $eventManager);
}
protected function _renderFiltersBefore() {
$user = $this->_authSession->getUser();
$joinTable = $this->getTable('sales_order');
$this->getSelect()->where('stockist_id = ' . $user->getId());
parent::_renderFiltersBefore();
}
}