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

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

        $criterion = $this->getCurrentCriterion($profile);

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

        if($criterion->equals($fields))
        {
            $fieldsProfileUpdate = array(
                "VERSION_1C" => $fields["VERSION_1C"],
                "NAME" => $fields["AGENT_NAME"],
                "USER_ID" => $profile->getUserId()
            );

            CSaleOrderUserProps::Update($profile->profileGetId(), $fieldsProfileUpdate);


            $profileFields = static::getFieldsUserProfile($profile->profileGetId());
            foreach($profileFields as $fieldsProfile)
            {
                $fieldsProfileByProperty[$fieldsProfile["ORDER_PROPS_ID"]] = array("ID" => $fieldsProfile["ID"], "VALUE" => $fieldsProfile["VALUE"]);
            }

            $propertyOrders = static::getPropertyOrdersByPersonalTypeId($profile->getPersonalTypeId());
            foreach($propertyOrders as $filedsProperty)
            {
                $propertyId = $filedsProperty["ID"];
                if(array_key_exists($propertyId, $property))
                {
                    $propertyByConfigValue = $property[$propertyId];
                    if(!empty($propertyByConfigValue))
                    {
                        $fields = array(
                            "USER_PROPS_ID" => $profile->getField("USER_PROFILE_ID"),
                            "ORDER_PROPS_ID" => $propertyId,
                            "NAME" => $filedsProperty["NAME"],
                            "VALUE" => $propertyByConfigValue
                        );

                        if(empty($fieldsProfileByProperty[$propertyId]))
                        {
                            CSaleOrderUserPropsValue::Add($fields);
                        }
                        elseif($fieldsProfileByProperty[$propertyId]["VALUE"] != $propertyByConfigValue)
                        {
                            CSaleOrderUserPropsValue::Update($fieldsProfileByProperty[$propertyId]["ID"], $fields);
                        }
                    }
                }
            }
        }
        return $result;
    }