S
S
saplas2019-06-11 18:25:19
1C-Bitrix
saplas, 2019-06-11 18:25:19

How to count the number of products per page?

There is a code that, in principle, counts the number of goods, but if you put a filter on the brand, then the number does not change in any way.

$count = 12;
if (isset($_GET['count'])) {
    $count = $_GET['count'];
    if ($_GET['count']==='showAll')
        $count=1000000000;
}

if (isset($_GET["sort"])) {
    $arParams["ELEMENT_SORT_FIELD"] = $_GET["sort"];
    $arParams["ELEMENT_SORT_ORDER"]= $_GET["order"];
}
$el = CIBlockElement::GetList(array('sort'=>'asc'), 
    array('IBLOCK_ID'=>$arParams['IBLOCK_ID'], 
        'IBLOCK_SECTION_ID'=>$sec['ID']), 
    false, false, 
    array('ID', 'NAME', ));
while ($elem = $el->GetNext()){
    global $elements;
    $elements[] = $elem;
}

<b class="middle "><?=count($elements)?></b>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-06-11
@saplas

$key=1;
while ($elem = $el->GetNext()){
    global $elements;
    $elements[] = $elem;
Skey++;
}
echo $key;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question