• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/dedupeparams.php
  • Класс: Bitrix\Crm\Integrity\DedupeParams
  • Вызов: DedupeParams::getCategoryId
public function getCategoryId(): ?int
{
	if (in_array($this->entityTypeID, [CCrmOwnerType::Contact, CCrmOwnerType::Company], true))
	{
		if ($this->categoryId > 0)
		{
			return $this->categoryId;
		}

		$factory = Container::getInstance()->getFactory($this->entityTypeID);
		if ($factory && $factory->isCategoriesEnabled())
		{
			$itemInCustomCategory = $factory->getDataClass()::query()
				->setLimit(1)
				->where(Item::FIELD_NAME_CATEGORY_ID, '>', 0)
				->setSelect(['ID'])
				->setCacheTtl(60)
				->fetch()
			;
			if ($itemInCustomCategory)
			{
				return $this->categoryId;
			}
		}
	}

	return null;
}