if($arFields["IBLOCK_ID"] == CATALOG_IBLOCK_ID_NEW)
{
$output = date('d.m.Y H:i:s') . ' UpdateSectionCode' . "\n";
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/success_events.log', $output, FILE_APPEND);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/event_UpdateSectionCode.log', var_export($arFields, true), FILE_APPEND);
$arParseName = array_unique(explode(" ", $arFields["NAME"]));
$arParseName = array_diff($arParseName, array(''));
$firstWord = current($arParseName);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/event_UpdateSectionCode.log', var_export($firstWord, true), FILE_APPEND);
if(is_numeric($firstWord))
{
unset($arParseName[0]);
$strCode = implode(" ", $arParseName);
$util = new Cutil;
$arParams = array(
"change_case" => "L",
"replace_space" => "_",
"replace_other" => "_",
"delete_repeat_replace" => true,
);
$arFields["CODE"] = $util->translit($strCode, "ru", $arParams)."_".$arFields["ID"];
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/event_UpdateSectionCode.log', var_export($arFields["CODE"], true), FILE_APPEND);
$output .= date('d.m.Y H:i:s') . ' UpdateSectionCode end' . "\n";
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/bitrix/success_events.log', $output, FILE_APPEND);
}