I
I
itemashabanov2021-08-05 11:46:36
1C-Bitrix
itemashabanov, 2021-08-05 11:46:36

Why is the selection of products in catalog.section reset?

Hello. It was necessary to display sliders with a selection of goods in the article in the complex component "news in detail". To do this, I prescribed a snag that allows you to insert components when editing a news item like on a regular page. In the code for calling these components, I specify FILTER_NAME => "FILTER_X", where X is the slider's ordinal number. In the infoblock properties I create properties with the filter name "FILTER_X". In the result_modifier.php file of the news component template, I check if this property is filled in the article, and if so, then I do this:

foreach($arFilterName as $val) {
  if(!empty($arResult["PROPERTIES"][$val]["VALUE"])) {
    $GLOBALS[$val] = ["ID" => $arResult["PROPERTIES"][$val]["VALUE"]];
  }
}

$arFilterName - array like ["FILTER_1", "FILTER_2"];
If you reset the cache - everything works, but when you refresh the page - just all the products in a row are displayed in the slider. It's as if the $GLOBALS array with filters is emptied during the update and an incorrect selection is obtained. Please advise how to solve the problem. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-08-06
@itemashabanov

if the layout allows and DETAIL_TEXT can still be moved to component_epilog, I can suggest putting macros in the detailed description, where the carousel should be. For example:
This is my test detailed description #KARUSEL_1# This is my test detailed description #KARUSEL_2#
In the component template you find out how many carousels through preg_match_all, in a loop you write catalog.sections with your filters to variables into the buffer, and then you replay these macros, before this is exactly what they did when the image gallery had to be inserted in the middle of a detailed description.
Here in my answer is an example of such a replay for prices. It will be more difficult for you, but similarly

ob_start();
  // вызов компонента
    $karusel_1 = ob_get_contents();
ob_end_clean();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question