Renderlife
11/13/2019 - 10:48 AM

Добавить раздел

public function addUpdSection($arFields, $id = 0)
    {
        $bs = new \CIBlockSection;
        $arFields = [
            "ACTIVE" => (isset($arFields['IBLOCK_SECTION_ID'])) ? $arFields['IBLOCK_SECTION_ID'] : true,
            "IBLOCK_SECTION_ID" => ($arFields['IBLOCK_SECTION_ID']) ?? '',
            "IBLOCK_ID" => $arFields['IBLOCK_ID'],
            "NAME" => $arFields['NAME'],
            "SORT" => ($arFields['SORT']) ?? 100,
            
            //"PICTURE" => $arFields['PICTURE'] //$_FILES["PICTURE"],
            //"DESCRIPTION" => $arFields['DESCRIPTION'],
            //"DESCRIPTION_TYPE" => $arFields['DESCRIPTION_TYPE']
        ];

        if ($id > 0) {
            $res = $bs->Update($ID, $arFields);
        } else {
            $id = $bs->Add($arFields);
            $res = ($id > 0);
        }

        if (!$res) {
            echo $bs->LAST_ERROR;
        }

        return $res;   
    }