A
A
Alexey Syrtsov2022-03-05 13:11:48
1C-Bitrix
Alexey Syrtsov, 2022-03-05 13:11:48

Why can the filter by sections in the catalog.section component not work in Bitrix?

I'm making a custom filter for a directory using the $arFilter global array.
The problem is the following: $arFilter['SECTION_ID'] does not work. The component simply ignores it. Moreover, filters like: $arFilter['ID'], $arFilter['PROPERTY_*property code*'] and others work fine.

I tried to change the name of the variable, replace $arFilter = $GLOBALS['arFilter'], clear the cache, pass the id sections as an array and a simple numeric value - the result is the same. Interestingly, $arFilter['IBLOCK_SECTION_ID'] works, but it doesn't work for me, because the elements are attached to several sections, and this filter does not take this into account

. Further, the song in general: I set the filter using $ arFilter['SECTION_CODE'] - and it worked for some time, but then, for reasons I do not understand,

I don't know where to dig anymore. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Syrtsov, 2022-03-05
@Siro4ek

Solved a problem. It turns out that if SECTION_ID is set in the component settings, the filter by it is ignored. The solution is obscenely simple - when calling catalog.section, check whether filtering is performed by SECTION_ID, and if so, leave this setting empty

"SECTION_ID" => !empty($GLOBALS[$arParams['FILTER_NAME']]['SECTION_ID']) ? '' : $arResult["VARIABLES"]["SECTION_ID"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question