• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicaterequisitecriterion.php
  • Класс: Bitrix\Crm\Integrity\DuplicateRequisiteCriterion
  • Вызов: DuplicateRequisiteCriterion::unregister
static function unregister($entityTypeID, $entityID, $countryId = 0, $fieldName = '')
{
	if(!is_int($entityTypeID))
	{
		throw new Main\ArgumentTypeException('entityTypeID', 'integer');
	}

	if(!is_int($entityID))
	{
		throw new Main\ArgumentTypeException('entityID', 'integer');
	}

	if(!is_int($countryId))
	{
		throw new Main\ArgumentTypeException('countryId', 'integer');
	}

	if(!is_string($fieldName))
	{
		throw new Main\ArgumentTypeException('fieldName', 'string');
	}

	$filter = array(
		'ENTITY_TYPE_ID' => $entityTypeID,
		'ENTITY_ID' => $entityID
	);

	$scope = null;
	if($countryId > 0)
	{
		$filter['RQ_COUNTRY_ID'] = $countryId;
		$scope = EntityRequisite::formatDuplicateCriterionScope($countryId);
	}

	if($fieldName !== '')
	{
		$filter['RQ_FIELD_NAME'] = $fieldName;
	}

	$dbResult = DuplicateRequisiteMatchCodeTable::getList(
		array(
			'select' =>array('ID'),
			'order' => array('ID' =>'ASC'),
			'filter' => $filter
		)
	);
	while($fields = $dbResult->fetch())
	{
		DuplicateRequisiteMatchCodeTable::delete($fields['ID']);
	}

	$typeId = DuplicateIndexType::resolveID($fieldName);
	if(in_array($typeId, self::getSupportedDedupeTypes(), true))
	{
		DuplicateEntityMatchHash::unregisterEntity($entityTypeID, $entityID, $typeId, $scope);
	}
	elseif($fieldName === '')
	{
		foreach (self::getSupportedDedupeTypes() as $typeId)
		{
			DuplicateEntityMatchHash::unregisterEntity($entityTypeID, $entityID, $typeId, $scope);
		}
	}
}