• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/entityaddresstype.php
  • Класс: Bitrix\Crm\EntityAddressType
  • Вызов: EntityAddressType::getDefaultIdByEntityId
static function getDefaultIdByEntityId(int $entityTypeId, int $entityId) : int
{
	$result = static::Undefined;

	if (CCrmOwnerType::IsDefined($entityTypeId) && $entityId > 0)
	{
		$factory = Container::getInstance()->getFactory($entityTypeId);

		if ($factory)
		{
			$categoryId = 0;

			if ($factory->isCategoriesSupported())
			{
				$item = $factory->getItem($entityId);
				if ($item)
				{
					$categoryId = $item->getCategoryId();
				}
			}

			if ($categoryId > 0 && $factory->isCategoryAvailable($categoryId))
			{
				$category = $factory->getCategory($categoryId);
				if ($category instanceof ItemCategory)
				{
					$result = $category->getDefaultAddressType();
				}
			}
		}
	}

	return $result;
}