A
A
Alexander2017-01-10 15:39:31
1C-Bitrix
Alexander, 2017-01-10 15:39:31

How to organize search by titles in Bitrix?

Tell me, is it possible somehow in the bitrix:catalog.search component to search only by the headers of the infoblock elements? It is in it that bitrix:search.title is not offered.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2017-11-22
@sergafon

The task is solved as follows
in init.php we insert

// Исключаем поиск по описаниям
AddEventHandler("search", "BeforeIndex", array("SearchHandlers", "BeforeIndexHandler"));

class SearchHandlers
{
    function BeforeIndexHandler($arFields)
    {
        if($arFields["MODULE_ID"] == "iblock")
        {
            if(array_key_exists("BODY", $arFields) && substr($arFields["ITEM_ID"], 0, 1) != "S") // Только для элементов
            {
                $arFields["BODY"] = "";
            }

            if (substr($arFields["ITEM_ID"], 0, 1) == "S") // Только для разделов
            {
                $arFields['TITLE'] = "";
                $arFields["BODY"] = "";
                $arFields['TAGS'] = "";
            }
        }

        return $arFields;
    }
}

Then you need to start reindexing in settings-search-reindexing. This event is fired when each element is reindexed. We have removed the description from the search index, so the search will no longer be performed on the description in any search component. For sections, we excluded the title, tags, and description so that they do not participate in the search at all.

A
Alexander Filippenko, 2017-01-10
@alexfilus

Remove the call to the search component, and replace the filter with
array("?NAME"=>$search_str);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question