Documentation

GetList

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

The method GetList returns properties of products sorted and optionally filtered. The parameters returned pertain to a product itself; these are not catalog element properties.

Parameters

ParameterDescription
by Field by which the returned collection entries are to be sorted. Can be one of the following:
  • ID - product ID (default);
  • QUANTITY - quantity of product items in stock;
  • QUANTITY_TRACE - "Y" tells the system to keep track of quantity of the product;
  • WEIGHT - product weight.
order Sort order. Can be one of the following:
  • ASC - ascending (default);
  • DESC - descending.
arFilter Filter by which entries are to be sorted. The filter is an associated array with the field names as keys and the conditions as values. The following values are used:
  • QUANTITY - quantity of product items in stock;
  • QUANTITY_TRACE - "Y" tells the system to keep track of quantity of the product;
  • WEIGHT - product weight.

Note
The filter allows only equation operator "=" ; it does not support operators like >, <= etc.

Return Values

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

Key Description
ID Product ID.
QUANTITY Quantity of product items in stock.
QUANTITY_TRACE "Y" tells the system to keep track of quantity of the product and decrement the counter upon successful order.
WEIGHT Product item weight.

Example



<?
//
// Display ID's of the first 10 products that are 
// most in stock and automatically tracked
//
$ind = 0;
$db_res = CCatalogProduct::GetList(($b="QUANTITY"),
                                   ($o="DESC"),
                                   array("QUANTITY_TRACE"=>"Y"));

while (($ar_res = $db_res->Fetch()) && ($ind < 10))
{
    echo $ar_res["ID"].", ";
    $ind++;
}
?>
© «Bitrix24», 2001-2024
Up