• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/exchange/profileimport.php
  • Класс: BitrixSaleExchangeProfileImport
  • Вызов: ProfileImport::initFieldsProfile
public function initFieldsProfile(array $fields, &$arErrors)
    {
        static $profiles = null;

        if($profiles[$fields['XML_ID']] === null)
        {
		$result = array();
        	$profile = static::getUserProfile(array('XML_ID'=>$fields['XML_ID']));

            if(!empty($profile))
            {
                $result['USER_ID'] = $profile['USER_ID'];
                $result['PERSON_TYPE_ID'] = $profile['PERSON_TYPE_ID'];

                $result['USER_PROFILE_ID'] = $profile['ID'];
                $result['USER_PROFILE_VERSION'] = $profile['VERSION_1C'];

                $profileFields = static::getFieldsUserProfile($profile['ID']);
                if(!empty($profileFields))
                {
                    foreach($profileFields as $profileField)
                    {
                        $result['USER_PROPS'][$profileField["ORDER_PROPS_ID"]] = $profileField["VALUE"];
                    }
                }
            }
            elseif($this->isImportable())
            {
                $result['PERSON_TYPE_ID'] = $this->resolvePersonTypeId($fields);

                $user = static::getUserByCode($fields['XML_ID']);
                if(!empty($user))
                    $result['USER_ID'] = $user['ID'];
                else
                    $result['USER_ID'] = $this->registerUser($fields, $arErrors);

                $result['USER_PROFILE_ID'] = null;
                $result['USER_PROFILE_VERSION'] = null;
                $result['USER_PROPS'] = null;
            }

            if(count($arErrors)>0)
            	return $result;
            else
            	$profiles[$fields['XML_ID']] = $result;
        }

        return $profiles[$fields['XML_ID']];
    }