Answer the question
In order to leave comments, you need to log in
How and where is the “BeforeIndex” event (before indexing) of an element called by the CSearch::Index method?
Good day!
I found an article: https://camouf.ru/blog-note/3081/ and everything seems to be clear, but I confused the text:
using the "BeforeIndex" event, which is called before the element is indexed by the CSearch::Index method
AddEventHandler("search", "BeforeIndex", "BeforeIndexHandler");
function BeforeIndexHandler($arFields) {
$arrIblock = array(48);
$arDelFields = array("DETAIL_TEXT", "PREVIEW_TEXT") ;
if (CModule::IncludeModule('iblock') && $arFields["MODULE_ID"] == 'iblock' && in_array($arFields["PARAM2"], $arrIblock) && intval($arFields["ITEM_ID"]) > 0){
$dbElement = CIblockElement::GetByID($arFields["ITEM_ID"]) ;
if ($arElement = $dbElement->Fetch()){
foreach ($arDelFields as $value){
if (isset ($arElement[$value]) && strlen($arElement[$value]) > 0){
$arFields["BODY"] = str_replace (CSearch::KillTags($arElement[$value]) , "", CSearch::KillTags($arFields["BODY"]) );
}
}
}
return $arFields;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question