Skip to main content

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $customers = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customers as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $customers = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customers as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $customers = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customers as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}
Improved formatting
Source Link
Rizwan Khan
  • 2k
  • 2
  • 18
  • 41

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $vendors$customers = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customer_id$customers as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $vendors = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customer_id as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $customers = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customers as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks

Source Link
Rizwan Khan
  • 2k
  • 2
  • 18
  • 41

In your Model Collection file you can use _renderFiltersBefore() method. like below i used.

protected function _renderFiltersBefore() {

        $filters = $this->request->getParam('filters');
        if (isset($filters['customer_id'])) { // your filter index in which you want filter callback
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $vendors = $objectManager->get('My\Custom\Model\MyModel')->create()
                    ->getCollection()
                    ->addAttributeToFilter('email', ['like' => '%' . $filters['customer_id'] . '%']);

            $customer_id = array();

            foreach ($customer_id as $customer) {
                $customer_id[] = $customer->getId();
                $this->getSelect()->orWhere("main_table.customer_id = '" . $customer->getId() . "'");
            }
        }
        
        parent::_renderFiltersBefore();
}

thanks