A
A
Anton2017-09-13 17:31:48
PHP
Anton, 2017-09-13 17:31:48

How to filter by property in Bitrix IBlockSection::GetList?

There is code that counts the number of elements in a section.
How to get the number of elements whose OTHER_COLORS property is filled?

<?
global $USER;
if ($USER->IsAdmin())
$sect = CIBlockSection::GetList(
    Array("sort"=>"asc", 'name'=>'asc'), 
    Array(
        'IBLOCK_ID'=>8, 
        'ID'=>2208,
        'ACTIVE'=>"Y",
        'CNT_ACTIVE'=>true
),
    true, 
    array('NAME')
);
while($el = $sect->Fetch()):
    $count += $el["ELEMENT_CNT"];
endwhile;
echo 'Товаров: '.$count;
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Emelyanov, 2017-09-13
@babarun

$arFilter = array(
    "IBLOCK_ID" => 8,
    "SECTION_CODE" => 2208,
    "INCLUDE_SUBSECTIONS" => "Y",
    "!PROPERTY_OTHER_COLORS" => false
);
$res = CIBlockElement::GetList(Array(), $arFilter);
echo 'Товаров: '.$res->SelectedRowsCount();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question