CrmLeads::search

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CrmLeads
  4. search
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/main/uiselector/crmleads.php
  • Класс: Bitrix\Crm\Integration\Main\UISelector\CrmLeads
  • Вызов: CrmLeads::search
public function search($params = [])
{
	$result = [
		'ITEMS' => [],
		'ADDITIONAL_INFO' => [],
	];

	$entityOptions = (!empty($params['options']) ? $params['options'] : []);
	$requestFields = (!empty($params['requestFields']) ? $params['requestFields'] : []);
	$search = $requestFields['searchString'];
	$prefix = static::getPrefix($entityOptions);

	if (
		$search <> ''
		&& (
			empty($entityOptions['enableSearch'])
			|| $entityOptions['enableSearch'] !== 'N'
		)
	)
	{
		$filter = $this->getSearchFilter($search, $entityOptions);

		if ($filter === false)
		{
			return $result;
		}

		$select = $this->getSearchSelect();

		$res = CCrmLead::getListEx(
			$this->getSearchOrder(),
			$filter,
			false,
			['nTopCount' => 20],
			$select
		);

		$resultItems = [];

		while ($entityFields = $res->fetch())
		{
			$resultItems[$prefix . $entityFields['ID']] = static::prepareEntity($entityFields, $entityOptions);
		}

		$resultItems = $this->appendItemsByIds($resultItems, $search, $entityOptions);

		$resultItems = $this->processResultItems($resultItems, $entityOptions);

		$result["ITEMS"] = $resultItems;
	}

	return $result;
}

Добавить комментарий