Answer the question
In order to leave comments, you need to log in
How to get a list of orders with products from a specific catalog?
The site has two product catalogs. You need to get all orders that have at least one product in the cart (to exclude broken orders without products), the products in which belong to a certain catalog (only the very first product can be checked). Any ideas how to do this better?
Answer the question
In order to leave comments, you need to log in
You can get an array with the ID of all such orders with one request.
\Bitrix\Main\Loader::includeModule("iblock");
\Bitrix\Main\Loader::includeModule("catalog");
\Bitrix\Main\Loader::includeModule("sale");
$ordersIds = array_column(\Bitrix\Sale\Internals\BasketTable::getList([
"select" => [
"ORDER_ID"
],
"filter" => [
"!ORDER_ID" => false,
"PRODUCT.IBLOCK.IBLOCK_ID" => $IBLOCK_ID//Тут надо задать ID вашего каталога
],
"group" => [
"ORDER_ID"
]
])->fetchAll(), "ORDER_ID");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question