if arFields IBLOCK_ID CATALOG_IBLOCK_ID_NE output date UpdateSectionCo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
}