Documentation

Update

int
CSaleLocation::Update(
  int ID,
  array arFields
);

The method Update replaces the location parameters with the new ones from the supplied array. The location country and city are updates as well.

Parameters

ParameterDescription
ID The location ID.
arFieldsAssosiated array of the location parameters. The following keys are possible:
  • SORT - sort weight;
  • COUNTRY_ID - the ID of the country currently existing in the system. If the country has not been previously created, the COUNTRY key must be specified;
  • COUNTRY - array contaning the country parameters (must be specified if the key COUNTRY_ID is not set or the key CHANGE_COUNTRY is set to "Y");
  • CHANGE_COUNTRY - specifies (Y/N) whether the country parameters should be changed (keys COUNTRY_ID and COUNTRY must be specified);
  • WITHOUT_CITY - specifies (Y/N) that the location has no city (country only). If set to "N", the CITY key must be specified;
  • CITY_ID - the city ID. If the city does not exist, this key must be set to null and the CITY key must be specified);
  • CITY - array with the city parameters (if WITHOUT_CITY is set to "Y", this key is optional).
The COUNTRY array must have the following keys specified:
  • NAME - the country name (language-independent);
  • SHORT_NAME - country name abbreviation (language-independent);
  • <language ID> - the key is the language name. The value is an associated array in the format:
    array("LID" => "language ID",
          "NAME" => "country name in this language",
          "SHORT_NAME" => "country name abbreviation in this language").
    Such pair must be specified for every language in the system.
The CITY array must have the following keys specified:
  • NAME - the city name (language-independent);
  • SHORT_NAME - city name abbreviation (language-independent);
  • <language ID> - the key is the language name. The value is an associated array in the format:
    array("LID" => "language ID",
          "NAME" => "city name in this language",
          "SHORT_NAME" => "city name abbreviation in this language").
    Such pair must be specified for every language in the system.

Returned values

Returns the modified location ID on success, or false otherwise.

Example


<?
$arFields = array(
   "SORT" => 100,
   "COUNTRY_ID" => 8,
   "WITHOUT_CITY" => "N"
);

$arCity = array(
   "NAME" => "Paris",
   "SHORT_NAME" => "Paris",
   "fr" => array(
      "LID" => "fr",
      "NAME" => "Paris",
      "SHORT_NAME" => "Paris"
      ),
   "en" => array(
      "LID" => "en",
      "NAME" => "Paris",
      "SHORT_NAME" => "Paris"
      )
);

$arFields["CITY"] = $arCity;

if (!CSaleLocation::Update(6, $arFields))
   echo "error updating location";
?>

© «Bitrix24», 2001-2024
Up