my task at my work is that i remove spaces from a frontend sku search (the one at top and the one after hitting enter). All sku's are formatted like AB 100001234, regexe and so on is ready to go.

If the user enters AB 10 00 01 23 4 magento should use AB 100001234.

Via interceptor i replaced the logic of Magento\Search\Model\QueryFactory->getRawQueryText() But this will affect to much or is this the right place?

Thanks a lot.


If at the top of your plugin you put this line, the change you make is quite unobtrusive.

if (preg_match("%^([A-Z]{2})([\s0-9]+)$%", $arg, $matches)) {
  // do something with the query
  • Thanks for the Reply. The "unobtrusive" was the magical word. Also i remembered that i could place the di.xml only in the frontend subfolder. – Philipp Jun 24 '20 at 7:28
  • indeed, great feedback, many thanks Phillip – Herve Tribouilloy Jun 24 '20 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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