• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/component/itemlist.php
  • Класс: Bitrix\Crm\Component\ItemList
  • Вызов: ItemList::initCategory
protected function initCategory(): ?Category
{
	$categoryId = (int) ($this->arParams['categoryId'] ?? null);
	$optionName = 'current_' . mb_strtolower($this->factory->getEntityName()) . '_category';

	if ($categoryId <= 0)
	{
		if (!$this->factory->isCategoriesEnabled())
		{
			return $this->factory->createDefaultCategoryIfNotExist();
		}

		\CUserOptions::DeleteOption('crm', $optionName);

		return null;
	}

	$category = $this->factory->getCategory($categoryId);

	if (!$category)
	{
		\CUserOptions::DeleteOption('crm', $optionName);

		$this->errorCollection[] = new Error(Loc::getMessage('CRM_TYPE_CATEGORY_NOT_FOUND_ERROR'));

		return null;
	}

	\CUserOptions::SetOption('crm', $optionName, $categoryId);

	return $category;
}