- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/location/migration/migrate.php
- Класс: BitrixSaleLocationMigrationCUpdaterLocationPro
- Вызов: CUpdaterLocationPro::createBaseTypes
static function createBaseTypes()
{
$types = array(
'COUNTRY' => array(
'CODE' => 'COUNTRY',
'SORT' => 100,
'DISPLAY_SORT' => 700,
'NAME' => array()
),
'REGION' => array(
'CODE' => 'REGION',
'SORT' => 300,
'DISPLAY_SORT' => 500,
'NAME' => array()
),
'CITY' => array(
'CODE' => 'CITY',
'SORT' => 600,
'DISPLAY_SORT' => 100,
'NAME' => array()
),
);
$langs = array();
$res = BitrixMainLocalizationLanguageTable::getList();
while($item = $res->Fetch())
{
$MESS = array();
@include($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/sale/lang/'.$item['LID'].'/lib/location/migration/migrate.php');
if(!empty($MESS))
{
$types['COUNTRY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_COUNTRY'];
$types['REGION']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_REGION'];
$types['CITY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_CITY'];
}
$langs[$item['LID']] = true;
}
$typeCode2Id = array();
$res = LocationTypeTable::getList(array('select' => array('ID', 'CODE')));
while($item = $res->Fetch())
$typeCode2Id[$item['CODE']] = $item['ID'];
foreach($types as $code => &$type)
{
foreach($langs as $lid => $f)
{
$type['NAME'][$lid] = BitrixSaleLocationAdminNameHelper::getTranslatedName($type['NAME'], $lid);
}
if(!isset($typeCode2Id[$type['CODE']]))
{
$typeCode2Id[$type['CODE']] = LocationTypeTable::add($type);
}
else
{
// ensure it has all appropriate translations
// we can not use ::updateMultipleForOwner() here, because user may rename types manually
LocationNameTypeTable::addAbsentForOwner($typeCode2Id[$type['CODE']], $type['NAME']);
}
}
return $typeCode2Id;
}