• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/defaultsite.php
  • Класс: BitrixSaleLocationDefaultSiteTable
  • Вызов: DefaultSiteTable::addMultipleForOwner
static function addMultipleForOwner($siteId, $locationCodeList = array())
{
	$siteId = static::checkSiteId($siteId);

	$existed = array();
	$res = self::getList(array('filter' => array('SITE_ID' => $siteId)));
	while($item = $res->fetch())
		$existed[$item['LOCATION_CODE']] = true;

	if(is_array($locationCodeList))
	{
		foreach($locationCodeList as $location)
		{
			if(!isset($existed[$location]))
			{
				$opRes = self::add(array(
					'SITE_ID' => $siteId,
					'LOCATION_CODE' => $location['LOCATION_CODE'],
					'SORT' => $location['SORT'],
				));
				if(!$opRes->isSuccess())
					throw new MainSystemException(Loc::getMessage('SALE_LOCATION_DEFAULTSITE_ENTITY_CANNOT_ADD_EXCEPTION'));
			}
		}
	}
	else
		throw new MainSystemException('Code list is not a valid array');

	$GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
}