P
P
po4emu4ka20202020-09-10 09:55:38
1C-Bitrix
po4emu4ka2020, 2020-09-10 09:55:38

Why does smart.filter start ignoring PREFILTER_NAME in Bitrix if filters related to trading offers are selected?

I can't figure out why some black magic is happening with my filtering.

I have a catalog.smart.filter , in which I pass 10 product IDs to PREFILTER_NAME.
And there is a catalog.section , in which I put in FILTER_NAME the filter that I received from catalog.smart.filter

Everything works fine if I select some filters that relate to products - "brand", "Product type" for example . But as soon as I choose the "size", which is available only for trade offers, the smart filter works out and displays ALL PRODUCTS OF THE CATALOG, where there is the desired size.

That is, the filter restriction that it is necessary to search only among my 10 IDs is simply ignored.
Do not understand why.

PS about 10 IDs - a convention, they will change dynamically.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-09-11
@po4emu4ka2020

The catalog.section uses the Bitrix\Iblock\Component\ElementList class, and for the getlist it merges the global filter array and the array with the internal filter array_merge($globalFilter, $filterFields) and $filterFields also has the =ID key, and when merging it overwrites your =ID
That is, in $prefilterCustom before ID, you need to remove =

$prefilterCustom = array(
  "ID" => $arElements,
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question