• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/delivery/externallocationmap.php
  • Класс: BitrixSaleDeliveryfor
  • Вызов: for::getExternalServiceId
static function getExternalServiceId()
{
	if(static::EXTERNAL_SERVICE_CODE == '')
		throw new SystemException('EXTERNAL_SERVICE_CODE must be defined!');

	static $result = null;

	if($result !== null)
		return $result;

	$res = ExternalServiceTable::getList(array(
		'filter' => array('=CODE' => static::EXTERNAL_SERVICE_CODE)
	));

	if($srv = $res->fetch())
	{
		$result = $srv['ID'];
		return $result;
	}

	$res = ExternalServiceTable::add(array('CODE' => static::EXTERNAL_SERVICE_CODE));

	if(!$res->isSuccess())
	{
		$result = 0;
		return $result;
	}

	$result =  $res->getId();
	return $result;
}