• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Factory.php
  • Класс: Bitrix\Crm\Service\Factory
  • Вызов: Factory::getItemCategoryId
public function getItemCategoryId(int $id): ?int
{
	if ($id === 0)
	{
		return null;
	}
	if (!$this->isCategoriesSupported())
	{
		return null;
	}

	if (array_key_exists($id, $this->itemsCategoryCache))
	{
		return $this->itemsCategoryCache[$id];
	}
	$this->itemsCategoryCache[$id] = null;

	$items = $this->getItems([
		'select' => [Item::FIELD_NAME_CATEGORY_ID],
		'filter' => [
			'=ID' => $id,
		]
	]);
	if (!empty($items))
	{
		$this->itemsCategoryCache[$id] = $items[0]->getCategoryId();
	}

	return $this->itemsCategoryCache[$id];
}