Получить список товаров по фильтру crm.product.list
Если вы разрабатываете интеграции для Битрикс24 с помощью AI-инструментов (Codex, Claude Code, Cursor), подключите MCP-сервер, чтобы ассистент использовал официальную REST-документацию.
Scope:
crmКто может выполнять метод: любой пользователь
DEPRECATED
Развитие метода остановлено. Используйте catalog.product.list.
Метод crm.product.list возвращает список товаров по фильтру.
Параметры метода
См. описание списочных методов.
Примеры кода
Как использовать примеры в документации
cURL (Webhook)
cURL (OAuth)
JS
PHP
BX24.js
PHP CRest
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>';
Скопировано
Предыдущая
Следующая