Получить список товаров по фильтру crm.product.list

Выберите инструмент для разработки с AI-агентом:

  • используйте Битрикс24 Вайбкод, чтобы создать приложение для Битрикс24 по описанию задачи без знания языков программирования. Агент напишет код и разместит приложение на сервере без ручной настройки хостинга
  • используйте MCP-сервер, чтобы разрабатывать интеграцию через REST API в своем проекте. Агент будет обращаться к официальной REST-документации

Scope: crm

Кто может выполнять метод: любой пользователь

DEPRECATED

Развитие метода остановлено. Используйте catalog.product.list.

Метод crm.product.list возвращает список товаров по фильтру.

Параметры метода

См. описание списочных методов.

Примеры кода

Как использовать примеры в документации

curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"order":{"NAME":"ASC"},"filter":{"CATALOG_ID":"your_catalog_id"},"select":["ID","NAME","CURRENCY_ID","PRICE"]}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.product.list
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"order":{"NAME":"ASC"},"filter":{"CATALOG_ID":"your_catalog_id"},"select":["ID","NAME","CURRENCY_ID","PRICE"],"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.product.list
// callListMethod: Получает все данные сразу. Используйте только для небольших выборок (< 1000 элементов) из-за высокой нагрузки на память.

var catalogId = prompt("Введите ID каталога");
try {
  const response = await $b24.callListMethod(
    'crm.product.list',
    {
      order: { "NAME": "ASC" },
      filter: { "CATALOG_ID": catalogId },
      select: [ "ID", "NAME", "CURRENCY_ID", "PRICE" ]
    },
    (progress) => { console.log('Progress:', progress) }
  )
  const items = response.getData() || []
  for (const entity of items) { console.log('Entity:', entity) }
} catch (error) {
  console.error('Request failed', error)
}

// fetchListMethod: Выбирает данные по частям с помощью итератора. Используйте для больших объемов данных для эффективного потребления памяти.

var catalogId = prompt("Введите ID каталога");
try {
  const generator = $b24.fetchListMethod('crm.product.list', {
    order: { "NAME": "ASC" },
    filter: { "CATALOG_ID": catalogId },
    select: [ "ID", "NAME", "CURRENCY_ID", "PRICE" ]
  }, 'ID')
  for await (const page of generator) {
    for (const entity of page) { console.log('Entity:', entity) }
  }
} catch (error) {
  console.error('Request failed', error)
}

// callMethod: Ручное управление постраничной навигацией через параметр start. Используйте для точного контроля над пакетами запросов. Для больших данных менее эффективен, чем fetchListMethod.

var catalogId = prompt("Введите ID каталога");
try {
  const response = await $b24.callMethod('crm.product.list', {
    order: { "NAME": "ASC" },
    filter: { "CATALOG_ID": catalogId },
    select: [ "ID", "NAME", "CURRENCY_ID", "PRICE" ]
  }, 0)
  const result = response.getData().result || []
  for (const entity of result) { console.log('Entity:', entity) }
} catch (error) {
  console.error('Request failed', error)
}
try {
    $order = []; // Define your order array
    $filter = []; // Define your filter array
    $select = ['ID', 'CATALOG_ID', 'PRICE', 'CURRENCY_ID', 'NAME', 'CODE', 'DESCRIPTION', 'DESCRIPTION_TYPE', 'ACTIVE', 'SECTION_ID', 'SORT', 'VAT_ID', 'VAT_INCLUDED', 'MEASURE', 'XML_ID', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'DATE_CREATE', 'TIMESTAMP_X', 'MODIFIED_BY', 'CREATED_BY'];
    $startItem = 0; // Define your start item
    $result = $serviceBuilder
        ->getCRMScope()
        ->product()
        ->list($order, $filter, $select, $startItem);
    foreach ($result->getProducts() as $product) {
        print("ID: {$product->ID}\n");
        print("Catalog ID: {$product->CATALOG_ID}\n");
        print("Price: {$product->PRICE}\n");
        print("Currency ID: {$product->CURRENCY_ID}\n");
        print("Name: {$product->NAME}\n");
        print("Code: {$product->CODE}\n");
        print("Description: {$product->DESCRIPTION}\n");
        print("Description Type: {$product->DESCRIPTION_TYPE}\n");
        print("Active: {$product->ACTIVE}\n");
        print("Section ID: {$product->SECTION_ID}\n");
        print("Sort: {$product->SORT}\n");
        print("VAT ID: {$product->VAT_ID}\n");
        print("VAT Included: {$product->VAT_INCLUDED}\n");
        print("Measure: {$product->MEASURE}\n");
        print("XML ID: {$product->XML_ID}\n");
        print("Preview Picture: {$product->PREVIEW_PICTURE}\n");
        print("Detail Picture: {$product->DETAIL_PICTURE}\n");
        print("Date Create: " . (new DateTime($product->DATE_CREATE))->format(DateTime::ATOM) . "\n");
        print("Timestamp X: " . (new DateTime($product->TIMESTAMP_X))->format(DateTime::ATOM) . "\n");
        print("Modified By: {$product->MODIFIED_BY}\n");
        print("Created By: {$product->CREATED_BY}\n");
    }
} catch (Throwable $e) {
    print("Error: " . $e->getMessage());
}
var catalogId = prompt("Введите ID каталога");
BX24.callMethod(
    "crm.product.list",
    {
        order: { "NAME": "ASC" },
        filter: { "CATALOG_ID": catalogId },
        select: [ "ID", "NAME", "CURRENCY_ID", "PRICE" ]
    },
    function(result)
    {
        if(result.error())
            console.error(result.error());
        else
        {
            console.dir(result.data());
            if(result.more())
                result.next();
        }
    }
);

Чтобы получить свойства товара, нужно в select указать PROPERTY_*.

$arFields['select'] = array('*', 'PROPERTY_*');
require_once('crest.php');

$catalogId = 'your_catalog_id'; // Replace 'your_catalog_id' with the actual catalog ID

$result = CRest::call(
    'crm.product.list',
    [
        'order' => ['NAME' => 'ASC'],
        'filter' => ['CATALOG_ID' => $catalogId],
        'select' => ['ID', 'NAME', 'CURRENCY_ID', 'PRICE']
    ]
);

echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "crm.product.list", b24.Params{
	"order": b24.Params{
		"NAME": "ASC",
	},
	"filter": b24.Params{
		"CATALOG_ID": "your_catalog_id",
	},
	"select": []string{"ID", "NAME", "CURRENCY_ID", "PRICE"},
}, b24.WithIdempotent())
if err != nil {
	return fmt.Errorf("crm.product.list: %w", err)
}

// Ответ приходит как json.RawMessage — разберите его
// в структуру под форму ответа, показанную ниже на этой странице.
fmt.Printf("%s\n", res.Result)