All my skus have the following format: XY-NAME-NUMBER, e.g BC-FLUID-0003.
Now when I try to search that sku via catalog search in the frontend, I get all kinds of results, much more than I'd like to have.
I enabled the SQL-Query Log and found out, that Magento changes my sku in the search to "bc fluid* 0003*" and therefore finds products which are also named something with fluid or also end with 0003.
What I want is to search for BC-FLUID-0003*, so without taking away the hyphens.
How could I do that?
Best Answer
This is because the internal handling of the parameter by Magento 2 Query Builder. The "-" symbol is prohibited in a search query (in Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match class). So it produces three small queries, in your case the final query looks similar to this:
To be able to find the product by SKU, I would suggest to make an around plugin like in this tread: How to get specific sku product on search in magento 2?