Documentation

GetList

This class has been deprecated. It's recommended to use methods of class Bitrix\Sale\Location.

CDBResult
CSaleLocation::GetList(
 array arOrder = 
       Array("SORT" => "ASC",
             "COUNTRY_NAME_LANG" => "ASC",
             "CITY_NAME_LANG" => "ASC"),
 array arFilter = Array(),
 string strLang = LANGUAGE_ID
);

The method GetList returns an optionally sorted and filtered list of locations. The list returned also contains parameters of the location countries and cities. Language-dependent parameters are returned for the language specified in the third parameter.

Parameters

ParameterDescription
arOrderAssociated array used to sort records. The sorting is performed consequently on each pair "key-value". Keys are the parameter names. Values are sort direction constants.

The following keys are possible:
  • SORT - sort weight;
  • COUNTRY_ID - the country ID;
  • ID - the location ID;
  • CITY_ID - the city ID;
  • COUNTRY_NAME - language independent country name;
  • CITY_NAME - language independent city name;
  • COUNTRY_NAME_LANG - language dependent country name;
  • CITY_NAME_LANG - language dependent city name.
Possible values:
  • ASC - ascending;
  • DESC - descending.
arFilterAssociated array used to filter records. Only the records which satisfy the filter are included in the returned list. Keys are the parameter names, and the values are conditions.

The following keys are possible:
  • COUNTRY_ID - the country ID;
  • ID - the location ID;
  • CITY_ID - the city ID;
  • COUNTRY - the country name;
  • CITY - the city name.
strLangThe ID of the language in which the language-dependent parameters will be returned. By default, the current language is used.

Returned values

Returns a CDBResult instance containing a set of associated arrays with the following keys.

Key Description
ID The location ID.
COUNTRY_ID The country ID.
CITY_ID The city ID.
SORT Sort weight.
COUNTRY_NAME_ORIG Language-independent country name.
COUNTRY_SHORT_NAME Short language-independent country name abbreviation.
COUNTRY_NAME_LANG Language-dependent country name.
CITY_NAME_ORIG Language-independent city name.
CITY_SHORT_NAME Short language-independent city name abbreviation.
CITY_NAME_LANG Language-dependent city name.
COUNTRY_NAME Language-dependent country name (if exists, or language-independent country name otherwise).
CITY_NAME Language-dependent country name (if exists, or language-independent country name otherwise).

Example


<?// Display a drop-down list of locations?>

<select name="LOCATION">
   <?
   $db_vars = CSaleLocation::GetList(Array("SORT"=>"ASC", 
                                           "COUNTRY_NAME_LANG"=>"ASC", 
                                           "CITY_NAME_LANG"=>"ASC"), 
                                           array(), LANGUAGE_ID);
   while ($vars = $db_vars->Fetch()):
      ?>
      <option value="<?= $vars["ID"]
        ?>"><?= htmlspecialchars($vars["COUNTRY_NAME"]." - ".
         $vars["CITY_NAME"])?></option>
      <?
   endwhile;
   ?>
</select>

© «Bitrix24», 2001-2024
Up