Magento 2 how to customize the search by keyword that’s above the orders grid and search for orders by telephone from sales order Address to search orders by billing or shipping telephone through my custom Module named Custom_SearchByTelephone
I tryied alot of codes but still didn’t work as
Override order collection
Renderfilterbefore
Renderfulltextbefore
Alot of codes but still didn’t return any data by telephone
<?php
namespace VendorNameModuleNamePlugin;
use MagentoSalesModelResourceModelOrderGridCollection as OrderGridCollection;
class OrderGridPlugin
{
public function aroundAddFieldToFilter(OrderGridCollection $subject, callable $proceed, $field, $condition = null)
{
// Check if we are filtering by telephone number.
if ($field === ‘billing_address.telephone’) {
// Modify condition as needed.
return $subject->addFieldToFilter(‘billing_address.telephone’, [‘like’ => ‘%’ . $condition . ‘%’]);
}
// Proceed with original method for other fields.
return $proceed($field, $condition);
}
}
And run all deploy commands, with reindex
But didn’t return any data by telephone search
However the filter working fine
But I need to use search by keyword,
Thanks in advance,