• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/search/ordersearchcontentbuilder.php
  • Класс: Bitrix\Crm\Search\OrderSearchContentBuilder
  • Вызов: OrderSearchContentBuilder::prepareEntityFields
protected function prepareEntityFields($entityID)
{
	$order = Order::load($entityID);
	if (!$order)
	{
		return $order;
	}

	$fields = $order->getFieldValues();
	foreach ($order->getContactCompanyCollection()->getContacts() as $contact)
	{
		$fields['CONTACT_IDS'][] = $contact->getField('ENTITY_ID');
	}

	$company = $order->getContactCompanyCollection()->getPrimaryCompany();
	if($company)
	{
		$fields['COMPANY_ID'] = $company->getField('ENTITY_ID');
	}

	foreach ($order->getPropertyCollection() as $property)
	{
		$allowedTypes = ['STRING', 'NUMBER', 'DATE'];
		if (in_array($property->getField('TYPE'), $allowedTypes) || empty($code))
		{
			continue;
		}

		$code = $property->getField('CODE');
		$value = $property->getValue();
		if ($code === 'PHONE')
		{
			$value = SearchEnvironment::prepareSearchContent($value);
		}
		$fields['PROPERTIES'][$code] = $value;
	}

	return is_array($fields) ? $fields : null;
}