• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/exchange/profileimport.php
  • Класс: BitrixSaleExchangeProfileImport
  • Вызов: ProfileImport::add
public function add(array $params)
    {
        $result = new SaleResult();

        /** @var static $profile */
        $profile = $this->getEntity();

        $fields = $params["TRAITS"];
        $property = $params["ORDER_PROP"];

        $propertyOrders = static::getPropertyOrdersByPersonalTypeId($profile->getPersonalTypeId());

        if(is_array($propertyOrders))
        {
            foreach($propertyOrders as $filedsProperty)
            {
                $propertyId = $filedsProperty["ID"];
                if(array_key_exists($propertyId, $property))
                {
                    $propertyByConfigValue = $property[$propertyId];
                    if($profile->profileGetId()<=0)
                    {
                        if(!empty($propertyByConfigValue))
                        {
                            $profileId = CSaleOrderUserProps::Add(array(
                                "NAME" => $fields["AGENT_NAME"],
                                "USER_ID" => $profile->getUserId(),
                                "PERSON_TYPE_ID" => $profile->getPersonalTypeId(),
                                "XML_ID" => $fields["XML_ID"],
                                "VERSION_1C" => $fields["VERSION_1C"]
                            ));

                            $profile->setField("USER_PROFILE_ID", $profileId);
                        }
                    }

                    CSaleOrderUserPropsValue::Add(array(
                        "USER_PROPS_ID" => $profile->profileGetId(),
                        "ORDER_PROPS_ID" => $propertyId,
                        "NAME" => $filedsProperty["NAME"],
                        "VALUE" => $propertyByConfigValue
                    ));
                }
            }
        }

        return $result;
    }