• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/actualentityselector.php
  • Класс: Bitrix\Crm\Integrity\ActualEntitySelector
  • Вызов: ActualEntitySelector::searchContact
protected function searchContact()
{
	$ranking = $this->rank(\CCrmOwnerType::Contact);
	if (!$ranking->getEntityId())
	{
		return;
	}

	$contactId = $ranking->getEntityId();
	$this->setContactId($contactId);
	$this->setContactOrders($ranking->getOrders());

	if ($this->getDynamicTypeId())
	{
		$this->setContactDynamics($ranking->getDynamics());
	}

	if (!$this->getDeals() && !$this->getReturnCustomerLeadId())
	{
		// set only if ::setEntity with deals or rc-leads didn't use
		$this->setContactDeals($ranking->getDeals());
		$this->setContactReturnCustomerLeads($ranking->getLeads());
	}

	if ($contactId)
	{
		$contactDb = ContactTable::getList(array(
			'select' => ['COMPANY_ID'],
			'filter' => ['=ID' => $contactId]
		));
		if (($contact = $contactDb->fetch()) && $contact['COMPANY_ID'])
		{
			$this->setContactCompanyId((int) $contact['COMPANY_ID']);
		}
	}
}