i'm using magento 2.3.4 and mysql search

I tried search on frontend example "ABC XYZ" text, but look like it searching which incl "ABC" or "XYZ"

I would like it show result which incl "ABC XYZ"

Is there any possible way to do it? Please help me, thank all

I also tried this but not work: https://magento.stackexchange.com/a/192763/77178

  • ABC XYZ is a product name ? Commented Mar 10, 2023 at 5:03

1 Answer 1

  1. Create a custom module: First, create a custom module in Magento 2. You can follow the official Magento 2 documentation to create a custom module.

  2. Create a di.xml file: Next, create a di.xml file in your module's etc directory. Add the following code to it:

     <type name="Magento\CatalogSearch\Model\Search\FilterMapper">
         <plugin name="change_search_condition" type="Vendor\Module\Plugin\Search\FilterMapper" sortOrder="1"/>

This code registers a plugin that will modify the search filter.

  1. Create a FilterMapper.php file: Create a FilterMapper.php file in your module's Plugin/Search directory. Add the following code to it:

         namespace Vendor\Module\Plugin\Search;
         use Magento\CatalogSearch\Model\Search\FilterMapper as MagentoFilterMapper;
         class FilterMapper
             public function afterBuild(MagentoFilterMapper $filterMapper, $result)
                 foreach ($result->getFilters() as $filter) {
                     if ($filter->getField() == 'search_term') {
                 return $result;

This code modifies the search filter by setting the condition type to "and" for the "search_term" field.

  1. Flush the cache: Finally, flush the cache to see the changes take effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.