create di.xml
file in app/code/Vendor/Module/etc/adminhtml/di.xml
and add below code
<?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\Reporting">
<plugin name="sales_grid_collection" type="Vendor\Module\Model\Plugin\Sales\Order\Grid"/>
</type>
</config>
create Grid.php
file in app/code/Vendor/Module/Model/Plugin/Sales/Order/Grid.php
and add below code
<?php
namespace Vendor\Module\Model\Plugin\Sales\Order;
class Grid {
public static $table = 'sales_order_grid';
protected $orderCollectionFactory;
public function __construct(
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
) {
$this->orderCollectionFactory = $orderCollectionFactory;
}
public function afterSearch($intercepter, $collection) {
//first you must check same function call or not with exit;
//echo "call function";exit;
if ($collection->getMainTable() === $collection->getConnection()->getTableName(self::$table)) {
$collection->addFieldToFilter('vendorname', array('eq' => 'CFM'));
}
return $collection;
}
}