• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/requisite/conversion/psrequisiteconverter.php
  • Класс: Bitrix\Crm\Requisite\Conversion\PSRequisiteConverter
  • Вызов: PSRequisiteConverter::saveEntities
static function saveEntities()
{
	if (self::$psEntityTreeMap === null)
		self::$psEntityTreeMap = array();

	if (is_array(self::$entityTree))
	{
		foreach (self::$entityTree as &$coInfo)
		{
			$companyId = self::findCompanyByTitle($coInfo['CO']['TITLE']);
			if ($companyId > 0)
			{
				$coInfo['IS_NEW'] = 'N';
				self::updateCompanyMF($companyId, $coInfo);
			}
			else
			{
				$companyId = self::addCompany($coInfo);
				$coInfo['IS_NEW'] = 'Y';
			}
			$coInfo['ID'] = $companyId;
			if ($companyId > 0)
			{
				if (is_array($coInfo['PS']))
				{
					foreach ($coInfo['PS'] as $psId)
					{
						self::$psEntityTreeMap[$psId] = array(
							'CO' => $companyId,
							'RQ' => 0,
							'BD' => 0
						);
					}
				}
				self::saveCompanyRequisite($coInfo);
			}
		}
		unset($coInfo);
		
		foreach (self::$psEntityTreeMap as $psId => $relations)
		{
			EntityPSRequisiteRelation::register(
				$psId,
				$relations['CO'],
				$relations['RQ'],
				$relations['BD']
			);
		}
	}
}