Answer the question
In order to leave comments, you need to log in
How to create more complex filters in getList?
Good afternoon.
Tell me how to create more complex filters in getList. For example, connections.
Here is an example.
Task: find out how many products are in the category with the test code
My solution:
My knowledge is only enough for such a solution
//ID категории
$sectionId = '';
// Получаем id категории по коду
$dbSection = \Bitrix\Iblock\SectionTable::getList([
'filter' => ['CODE' => 'test']
]);
while ($arSection = $dbSection->fetchAll()){
$sectionId = $arSection[0]['ID'];
}
//Получаем количество товаров
$dbItems = ElementTable::getCount([
'IBLOCK_ID' => $arParams['IBLOCK_ID'],
'IBLOCK_SECTION_ID' => $sectionId
]);
//Получили количество
var_dump($dbItems);
$dbItems = ElementTable::getCount([
'filter' => [
'IBLOCK_ID' => $arParams['IBLOCK_ID'],
'SECTION.CODE' => 'test'
]
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question