Untitled
raw download clone
TEXT
views 20
,
size 672 b
function AddCategory($params) {

		$bs = new CIBlockSection;
		$arFields = Array(
			"IBLOCK_ID" => $this->IBLOCK_ID,
			"NAME" => $params['NAME'],
			"CODE" => $params['CODE'],
		);

		if( $params['PARENT_ID'] != '' ) {
			$params['PARENT_ID'] = $params['ID'];
			$arFields['IBLOCK_SECTION_ID'] = CIBlockSection::GetByID($arResult["PARENT_ID"]);
		}

		// Существует или нет
		$ID = $this->GetSectionByCode($params['ID']);


		if( !$ID ) {

			if( $params['DELETED'] == 1 ) {
				CIBlockSection::Delete($ID);
			} else {
				$ID = $bs->Add($arFields);
			}

		} else {
			$bs->Update($ID, $arFields);
		}

		return $ID;

	}
close fullscreen
Login or Register to edit or fork this paste. It's free.