diff --git a/app/code/Magento/Search/Model/SynonymAnalyzer.php b/app/code/Magento/Search/Model/SynonymAnalyzer.php index 06d5c1eda0631..b022f47efebd5 100644 --- a/app/code/Magento/Search/Model/SynonymAnalyzer.php +++ b/app/code/Magento/Search/Model/SynonymAnalyzer.php @@ -137,8 +137,10 @@ private function getSearchPattern(array $words): string { $patterns = []; for ($lastItem = count($words); $lastItem > 0; $lastItem--) { + $words = array_map(function ($word) { + return preg_quote($word, '/'); + }, $words); $phrase = implode("\s+", \array_slice($words, 0, $lastItem)); - $phrase = preg_quote($phrase, '/'); $patterns[] = '^' . $phrase . ','; $patterns[] = ',' . $phrase . ','; $patterns[] = ',' . $phrase . '$'; diff --git a/dev/tests/integration/testsuite/Magento/Search/Model/SynonymAnalyzerTest.php b/dev/tests/integration/testsuite/Magento/Search/Model/SynonymAnalyzerTest.php index 173cdf8a64703..2531f9c60f070 100644 --- a/dev/tests/integration/testsuite/Magento/Search/Model/SynonymAnalyzerTest.php +++ b/dev/tests/integration/testsuite/Magento/Search/Model/SynonymAnalyzerTest.php @@ -78,6 +78,10 @@ public static function loadGetSynonymsForPhraseDataProvider() 'phrase' => 'schlicht', 'expectedResult' => [['schlicht', 'natürlich']] ], + 'withSlashInSearchPhrase' => [ + 'phrase' => 'orange hill/peak', + 'expectedResult' => [['orange', 'magento'], ['hill/peak']] + ], ]; }