BasePersonalize::addAddressFieldsValue

  1. Bitrix24 API (v. 23.675.0)
  2. sender
  3. BasePersonalize
  4. addAddressFieldsValue
  • Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/crm/connectors/personalize/basepersonalize.php
  • Класс: Bitrix\Sender\Integration\Crm\Connectors\Personalize\BasePersonalize
  • Вызов: BasePersonalize::addAddressFieldsValue
static function addAddressFieldsValue($entityType, $usedFields, &$objDocument)
{
	$rqAddr = new Bitrix\Crm\RequisiteAddress();

	$res = $rqAddr->getList(
		array(
			'filter' => array(
				'ENTITY_TYPE_ID' => \CCrmOwnerType::Requisite,
				'ANCHOR_TYPE_ID' => \CCrmOwnerType::ResolveID($entityType),
				'ANCHOR_ID' => $objDocument['ID']
			),
			'select' => array(
				'ADDRESS_TYPE_ID' => 'TYPE_ID',
				'ADDRESS' => 'ADDRESS_1',
				'ADDRESS_2',
				'ADDRESS_CITY' => 'CITY',
				'ADDRESS_POSTAL_CODE' => 'POSTAL_CODE',
				'ADDRESS_REGION' => 'REGION',
				'ADDRESS_PROVINCE' => 'PROVINCE',
				'ADDRESS_COUNTRY' => 'COUNTRY',
				'ADDRESS_COUNTRY_CODE' => 'COUNTRY_CODE'
			)
		)
	)->fetchAll();

	if(!$res)
	{
		return;
	}

	foreach ($res as $addresses)
	{
		if(
			(int)$addresses['ADDRESS_TYPE_ID'] === (int)\Bitrix\Crm\EntityAddressType::Primary
		)
		{
			foreach ($addresses as $key => $address)
			{
				$objDocument[$key] = $address;
			}
		}
		if(isset($usedFields[strtoupper($entityType).'.ADDRESS_LEGAL']) &&
			(int)$addresses['ADDRESS_TYPE_ID'] === \Bitrix\Crm\EntityAddressType::Registered)
		{
			$objDocument['ADDRESS_LEGAL'] = self::buildAddress($entityType, $addresses);
		}
	}
}

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