M
M
Maxim Volkov2020-06-16 16:31:05
1C-Bitrix
Maxim Volkov, 2020-06-16 16:31:05

Why doesn't the filter for selecting infoblock elements by ID work?

The task is to display the "Related Products" of the catalog - elements of the infoblock by ID. Related products - are bound through a property - as a result, I get an array of data with an ID - the necessary products.
$arResult["PROPERTIES"]["ASSOCIATED"]["VALUE"]
Array
(
[0] => 1400
[1] => 966
[2] => 997
[3] => 1002
[4] => 1009
[ 5] => 1013
[6] => 1017
[7] => 1019
[8] => 1012
[9] => 1000
)
To display selected items, I use the catalog.section component , with the settings:
"USE_FILTER" => "Y",

" FILTER_NAME
" => "arrAssociated " "]["ASSOCIATED"]["VALUE"]) ;

Does not work, products are not displayed by the filter, but if you pass the ID data in the form -

$GLOBALS["arrAssociated"] = array('ID' => array(1400, 966, 997, 1002, 1009) )
Everything works out successfully.

How to bring the data from the array => $arResult["PROPERTIES"]["ASSOCIATED"]["VALUE"] to the correct form so that the filter works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Volkov, 2020-06-22
@voland700

Problem solved - solutions are in the comments.
The essence of the problem is that the data contained in $arResult in the component.epilog.php file is not available. To pass the necessary parameters contained in $arResult, you need to pass them from the cached area of ​​the component to component_epilog.php:

$cp = $this->__component;
if (is_object($cp))
{
  $cp->arResult["ASSOCIATED"] = $arResult["PROPERTIES"]["ASSOCIATED"]["VALUE"];
  $cp->SetResultCacheKeys(array("ASSOCIATED")); //cache keys in $arResult array
}

Or pass component settings parameters via $arParams:
$templateData["ASSOCIATED"] = $arResult["PROPERTIES"]["ASSOCIATED"]["VALUE"];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question