Documentation

GetList

CDBResult
CPrice::GetList(
 string &by, 
 string &order, 
 array arFilter = Array()
);

The method GetList returns a set of arrays each describing a single price. The set returned is sorted and optionally filtered.

Parameters

ParameterDescription
by Name of the field by which the list of prices is to be sorted. Names include the following:
  • ID - price ID (default);
  • PRODUCT_ID - product ID;
  • EXTRA_ID - discount ID;
  • CATALOG_GROUP_ID - price type ID;
  • PRICE - price value;
  • CURRENCY - currency of price;
  • SORT - price type sort weight.
order Sort order. Can be one of the following:
  • ASC - ascending (default);
  • DESC - descending.
arFilter Array with fields by which the returned prices are to be filtered. Keys are the field names; values are conditions. The array can have the following keys:
  • PRODUCT_ID - product ID;
  • EXTRA_ID - discount ID;
  • CATALOG_GROUP_ID - price type ID;
  • CURRENCY - currency;
  • BASE - flag "base price type".
Current version of the filter allows to specify negation operations by inserting the symbol ! at the beginning of the key value.

Return Values

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

Key Description
ID Price ID.
PRODUCT_ID Product ID.
EXTRA_ID The ID of a discount (or extra).
CATALOG_GROUP_ID Price type ID.
PRICE Price value.
CURRENCY Currency.
CAN_ACCESS If "Y", the current user is allowed to view prices of this type. If "N", prices of this type should be hidden.
CAN_BUY If "Y", the current user is allowed to purchase at prices of this type. Otherwise "N".
CATALOG_GROUP_NAME Name of the price type in the current language.

 

Example



<?
// Display a price of the type $PRICE_TYPE_ID for the product $PRODUCT_ID
$db_res = CPrice::GetList(($b=""),
                          ($o=""),
                          Array("PRODUCT_ID"=>$PRODUCT_ID,
                                "CATALOG_GROUP_ID"=>$PRICE_TYPE_ID));

if ($ar_res = $db_res->Fetch())
{
    echo CurrencyFormat($ar_res["PRICE"],
                        $ar_res["CURRENCY"]);
}
else
{
    echo "Price not found!";
}
?>
© «Bitrix24», 2001-2024