• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/actualentityselector.php
  • Класс: Bitrix\Crm\Integrity\ActualEntitySelector
  • Вызов: ActualEntitySelector::search
public function search()
{
	// check for exclusions
	if ($this->isExclusionCheckingEnabled && !$this->checkForExclusions())
	{
		$this->duplicates = [];
		return $this;
	}

	$this->duplicates = $this->findDuplicates();
	if (count($this->duplicates) == 0 && !$this->hasEntities())
	{
		// stop searching if no duplicates and no entities set manually
		return $this;
	}

	$this->searchCompany();
	$this->searchContact();
	if ($this->isFullSearchEnabled || (!$this->getCompanyId() && !$this->getContactId()))
	{
		$this->searchLead();
	}

	if ($this->getCompanyDeals())
	{
		$this->setDeals($this->getCompanyDeals());
	}
	else if ($this->getContactDeals())
	{
		$this->setDeals($this->getContactDeals());
	}

	if (!empty($this->getCompanyOrders()))
	{
		$this->setOrders($this->getCompanyOrders());
	}
	else if (!empty($this->getContactOrders()))
	{
		$this->setOrders($this->getContactOrders());
	}

	if (!empty($this->getCompanyDynamics()))
	{
		$this->setDynamics($this->getCompanyDynamics());
	}
	else if (!empty($this->getContactDynamics()))
	{
		$this->setDynamics($this->getContactDynamics());
	}

	if ($this->getCompanyReturnCustomerLeads())
	{
		$this->setReturnCustomerLeads($this->getCompanyReturnCustomerLeads());
	}
	else if ($this->getContactReturnCustomerLeads())
	{
		$this->setReturnCustomerLeads($this->getContactReturnCustomerLeads());
	}

	return $this;
}