• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/import/import.php
  • Класс: BitrixSaleLocationImportImportProcess
  • Вызов: ImportProcess::convertBlock
public function convertBlock($block)
{
	$converted = array();

	foreach($block as $line)
	{
		if($line[0] == 'S')
			$typeCode = 'COUNTRY';
		elseif($line[0] == 'R')
			$typeCode = 'REGION';
		elseif($line[0] == 'T')
			$typeCode = 'CITY';
		else
			throw new MainSystemException('Unknown type found in legacy file');

		$code = md5(implode(':', $line));

		if($typeCode == 'REGION')
			$parentCode = $this->data['current']['legacy']['lastCOUNTRY'];
		elseif($typeCode == 'CITY')
			$parentCode = $this->data['current']['legacy']['lastParent'];
		else
			$parentCode = '';

		if($typeCode != 'CITY')
		{
			$this->data['current']['legacy']['last'.$typeCode] = $code;
			$this->data['current']['legacy']['lastParent'] = $code;
		}

		$cLine = array(
			'CODE' => $code,
			'TYPE_CODE' => $typeCode,
			'PARENT_CODE' => $parentCode
		);

		$lang = false;
		$expectLang = true;
		$lineLen = count($line);
		for($k = 1; $k < $lineLen; $k++)
		{
			if($expectLang)
				$lang = $line[$k];
			else
				$cLine['NAME'][$lang]['NAME'] = $line[$k];

			$expectLang = !$expectLang;
		}

		$converted[] = $cLine;
	}

	return $converted;
}