D
D
Dmitry Krupin2021-05-14 15:09:11
1C-Bitrix
Dmitry Krupin, 2021-05-14 15:09:11

How to get the ID of the current open product category in Bitrix?

I want to display subcategories for each product category.

I do it like this:

$APPLICATION->IncludeComponent(
  "bitrix:catalog.section.list", 
  "template1", 
  array(
    "ADD_SECTIONS_CHAIN" => "Y",
    "CACHE_FILTER" => "N",
    "CACHE_GROUPS" => "Y",
    "CACHE_TIME" => "36000000",
    "CACHE_TYPE" => "A",
    "COMPONENT_TEMPLATE" => "template1",
    "COUNT_ELEMENTS" => "Y",
    "FILTER_NAME" => "sectionsFilter",
    "HIDE_SECTION_NAME" => "N",
    "IBLOCK_ID" => "4",
    "IBLOCK_TYPE" => "catalog",
    "SECTION_CODE" => $_REQUEST["SECTION_CODE"],
    "SECTION_FIELDS" => array(
      0 => "NAME",
      1 => "PICTURE",
      2 => "",
    ),
    "SECTION_ID" => ,
    "SECTION_URL" => "/catalog/#SECTION_CODE#/",
    "SECTION_USER_FIELDS" => array(
      0 => "",
      1 => "",
    ),
    "SHOW_PARENT_NAME" => "Y",
    "TOP_DEPTH" => "3",
    "VIEW_MODE" => "TILE"
  ),
  false
); */


And everything is OK, it remains only to insert the desired ID in the "SECTION_ID" field
Tried like this:

$rsSections = CIBlockSection::GetList(array(),array('IBLOCK_ID' => $arParams ['IBLOCK_ID'], '=CODE' => $arResult['VARIABLES']['SECTION_CODE']));
$arSection = $rsSections->Fetch();


But for some reason the same ID is issued in any section. And the partition structure itself, even in breadcrumbs, begins to appear as if the entire directory lies in the section whose ID is displayed.

What's wrong? Is there a simple solution to my problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Alexandrov, 2021-05-17
@DmitrySamohin

I see a complex component of the catalog there, you can get this value $arResult['VARIABLES']['SECTION_CODE'] in the template files of the complex component.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question