A
A
Alexer052019-01-28 14:27:23
1C-Bitrix
Alexer05, 2019-01-28 14:27:23

How to add a phrase to search statistics?

We have our own search component on the site, but it does not save phrases in search statistics (Settings / Search / Statistics / List of phrases). How can I add phrases to search statistics?
The search is done through the code below:

$obSearch = new CSearch;
$Q = htmlentities($_REQUEST["q"]);
$obSearch->Search(array(
    "QUERY"       => $DB->ForSql($Q),
    "SITE_ID"     => LANG,
    "MODULE_ID"   => "iblock",
    "PARAM1"      => "catalog"
));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kudis, 2019-01-29
@Alexer05

Do you have the statistics collection option enabled: Settings / Product settings / Module settings / Search, Statistics tab, checkbox Collect statistics for search phrases?
If yes, then you can add the phrase to the statistics in the same way as Bitrix itself does.

CModule::IncludeModule("search");
if (COption::GetOptionString("search", "stat_phrase") == "Y")
{
    $statistic = new CSearchStatistic('kudis.ru', '1С-Битрикс,Битрикс24');
    $statistic->PhraseStat(12, 3);
}

PhraseStat(number of items found, number of pagination pages)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question