CCrmProductSection::Delete

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProductSection
  4. Delete
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product_section.php
  • Класс: \CCrmProductSection
  • Вызов: CCrmProductSection::Delete
static function Delete($ID)
{
	if (!CModule::IncludeModule('iblock'))
	{
		return false;
	}

	$section = new CIBlockSection();
	$dbResult = $section->GetList(
		array(),
		array(
			'ID' => $ID,
			/*'GLOBAL_ACTIVE' => 'Y',*/
			'CHECK_PERMISSIONS' => 'N'
		),
		false,
		array('IBLOCK_ID'),
		false
	);

	$currentFields = $dbResult ? $dbResult->Fetch() : null;
	if(!(is_array($currentFields) && CCrmCatalog::Exists(intval($currentFields['IBLOCK_ID']))))
	{
		self::$LAST_ERROR_CODE = self::ERR_SECTION_NOT_FOUND;
		self::$LAST_ERROR = GetMessage('CRM_PRODUCT_SECTION_ERR_NOT_FOUND');
		return false;
	}

	if (self::isIncludesUsedProducts($currentFields['IBLOCK_ID'], $ID))
	{
		// Section includes used products
		self::$LAST_ERROR_CODE = self::ERR_SECTION_INCLUDES_USED_PRODUCTS;
		self::$LAST_ERROR = GetMessage('CRM_PRODUCT_SECTION_ERR_SECTION_INCLUDES_USED_PRODUCTS');
		return false;
	}

	$result = $section->Delete($ID, false);
	if($result === false)
	{
		self::$LAST_ERROR_CODE = self::ERR_IBLOCK_SECTION_DELETE;
		self::$LAST_ERROR = $section->LAST_ERROR;
	}
	return $result !== false;
}

Добавить комментарий