Y
Y
Yuriy2018-05-08 17:31:01
1C-Bitrix
Yuriy, 2018-05-08 17:31:01

Bitrix search component, replacement of entered words?

Tell me how to implement the replacement of the entered words, phrases from the user with the necessary words, phrases?
for example, the buyer enters "insulation" in the search string, but there are no such products or sections on the site, but there is "thermal insulation", so as not to give an empty result, the buyer can be directed to these products or sections.
Or the buyer simply made a mistake in the company, the name of the product, i.e. entered with an error, for example, "kerpich", and we fix it to
"kerpich" using regular expressions.
are there standard solutions?
and how best to implement it, with the constant filling of the base of such words, phrases - substitutions.
is it possible to add regexp for these purposes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Irina, 2018-05-09
@iitovka

1) Either customize the component, and before fetching getlist add it to your additional parameters in the filter, or in the component template, if the result is empty, then reconnect the component with its own filter, depending on the search phrase. 1 is better, because so everything will be found at once.
2) for brick / brick I use the service from Yandex - https://tech.yandex.ru/speller/
because Since I customized the component, I just check the search query and add it to the filter via LOGIC->OR.
request code
function yaapi($url, $params) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURLOPT_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$result = json_decode(yaapi(' speller.yandex.net/services/spellservice.json/checkText ', array('text'=>$arrFilter['?NAME'])), true);
$arrFilter['?NAME'] - user search query

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question