P
P
pareshok2019-06-05 16:56:52
1C-Bitrix
pareshok, 2019-06-05 16:56:52

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

1 answer(s)
R
Roman Gritsuk, 2019-06-06
@pareshok

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 question

Ask a Question

731 491 924 answers to any question