CCrmProduct::CheckFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProduct
  4. CheckFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product.php
  • Класс: \CCrmProduct
  • Вызов: CCrmProduct::CheckFields
static function CheckFields($sAction, &$arFields, $ID)
{
	if($sAction == 'ADD')
	{
		if (!is_set($arFields, 'ID'))
		{
			self::RegisterError('Could not find ID. ID that is treated as a IBLOCK_ELEMENT_ID.');
			return false;
		}

		$elementID = intval($arFields['ID']);
		if($elementID <= 0)
		{
			self::RegisterError('ID that is treated as a IBLOCK_ELEMENT_ID is invalid.');
			return false;
		}

		if (!self::IsIBlockElementExists($elementID))
		{
			self::RegisterError("Could not find IBlockElement(ID = $elementID).");
			return false;
		}

		if (!is_set($arFields, 'CATALOG_ID'))
		{
			self::RegisterError('Could not find CATALOG_ID. CATALOG_ID that is treated as a IBLOCK_ID.');
			return false;
		}

		$blockID = intval($arFields['CATALOG_ID']);
		if($blockID <= 0)
		{
			self::RegisterError('CATALOG_ID that is treated as a IBLOCK_ID is invalid.');
			return false;
		}

		$blocks = CIBlock::GetList(array(), array('ID' => $blockID), false);
		if (!($blocks = $blocks->Fetch()))
		{
			self::RegisterError("Could not find IBlock(ID = $blockID).");
			return false;
		}
	}
	else//if($sAction == 'UPDATE')
	{
		if(!self::Exists($ID))
		{
			self::RegisterError("Could not find CrmProduct(ID = $ID).");
			return false;
		}
	}

	return true;
}

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