Crmgo Blog

Bitrix: Search by Code in the Smart Filter

Bitrix: Search by Code in the Smart Filter

Attention! This method involves editing a Bitrix core file; upon updating Bitrix, your changes will be overwritten. To add the code to the index when creating or importing a new product, edit: ./bitrix/modules/iblock/classes/mysql/iblockelement.php Find: Replace with: To index already uploaded products, create and run php…

Bitrix: Search by Code in the Smart Filter

Attention! This method edits a Bitrix core file; upon updating Bitrix, the changes will be overwritten.

To add the code to the index when creating or importing a new product, edit:

./bitrix/modules/iblock/classes/mysql/iblockelement.php

Find:

$arFields["SEARCHABLE_CONTENT"] = ToUpper(
(is_set($arFields, "NAME")? $arFields["NAME"]: $ar_wf_element["NAME"])."\r\n".
($PREVIEW_TYPE_tmp=="html"? HTMLToTxt($PREVIEW_tmp): $PREVIEW_tmp)."\r\n".
($DETAIL_TYPE_tmp=="html"? HTMLToTxt($DETAIL_tmp): $DETAIL_tmp)
);

 

Replace with:

$arFields["SEARCHABLE_CONTENT"] = ToUpper(
(is_set($arFields, "NAME")? $arFields["NAME"]: $ar_wf_element["NAME"])."\r\n".
($PREVIEW_TYPE_tmp=="html"? HTMLToTxt($PREVIEW_tmp): $PREVIEW_tmp)."\r\n".
($DETAIL_TYPE_tmp=="html"? HTMLToTxt($DETAIL_tmp): $DETAIL_tmp)."\r\n".
$arFields["CODE"]
);

 

To index already uploaded products, create and execute a PHP file with the following content:

<? 
;require($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn.php"); 
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); 
;require($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect.php"); 
$query = "UPDATE `b_iblock_element` SET `SEARCHABLE_CONTENT`= concat(`NAME`,' ',`CODE`) WHERE `IBLOCK_ID`= '32'"; 
$result = $DB->Query($query); 
$row=$result->Fetch(); 
print_r($row);

?>

 

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.