P
P
pavelmosin2020-08-25 12:11:15
1C-Bitrix
pavelmosin, 2020-08-25 12:11:15

A working option for filtering the entire catalog (bitrix:catalog.smart.filter in sections.php)?

Good afternoon!
The task is as follows: display all the products of the catalog in the root of the catalog with the possibility of filtering them through bitrix:catalog.smart.filter.
I tried all the options from the TOP queries on the question, but nothing works if the CNC is enabled.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pavelmosin, 2020-08-25
@pavelmosin

As a result, this filter code worked + specify in the catalog.section parameters after the filter
"BY_LINK"=> "Y",
"SHOW_ALL_WO_SECTION" => "Y",
"SECTION_ID" => '0',

<?
      $arFilter = array(
        "IBLOCK_ID" => $arParams["IBLOCK_ID"],
        "ACTIVE" => "Y",
        "GLOBAL_ACTIVE" => "Y",
      );
      if (0 < intval($arResult["VARIABLES"]["SECTION_ID"])) {
        $arFilter["ID"] = $arResult["VARIABLES"]["SECTION_ID"];
      }
      elseif ('' != $arResult["VARIABLES"]["SECTION_CODE"]) {
        $arFilter["=CODE"] = $arResult["VARIABLES"]["SECTION_CODE"];
      }

      $obCache = new CPHPCache();
      if ($obCache->InitCache(36000, serialize($arFilter), "/iblock/catalog")) {
        $arCurSection = $obCache->GetVars();
      } elseif ($obCache->StartDataCache()) {
        $arCurSection = array();
        if (Loader::includeModule("iblock")) {
          $dbRes = CIBlockSection::GetList(array(), $arFilter, false, array("ID"));

          if(defined("BX_COMP_MANAGED_CACHE")) {
            global $CACHE_MANAGER;
            $CACHE_MANAGER->StartTagCache("/iblock/catalog");

            if ($arCurSection = $dbRes->Fetch()) {
              $CACHE_MANAGER->RegisterTag("iblock_id_".$arParams["IBLOCK_ID"]);
            }
            $CACHE_MANAGER->EndTagCache();
          } else {
            if(!$arCurSection = $dbRes->Fetch()) {
              $arCurSection = array();
            }
          }
        }
        $obCache->EndDataCache($arCurSection);
      }
      if (!isset($arCurSection)) {
        $arCurSection = array();
      }



      $APPLICATION->IncludeComponent(
        "bitrix:catalog.smart.filter",
        ".default",
        array(
          "PREFILTER_NAME" => $arParams["FILTER_NAME"],
          "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
          "IBLOCK_ID" => $arParams["IBLOCK_ID"],
          "SECTION_ID" => '0',
          "FILTER_NAME" => $arParams["FILTER_NAME"],
          "PRICE_CODE" => $arParams["PRICE_CODE"],
          "CACHE_TYPE" => $arParams["CACHE_TYPE"],
          "CACHE_TIME" => $arParams["CACHE_TIME"],
          "CACHE_GROUPS" => $arParams["CACHE_GROUPS"],
          "SAVE_IN_SESSION" => "N",
          "FILTER_VIEW_MODE" => $arParams["FILTER_VIEW_MODE"],
          "XML_EXPORT" => "Y",
          "SECTION_TITLE" => "NAME",
          "SECTION_DESCRIPTION" => "DESCRIPTION",
          'HIDE_NOT_AVAILABLE' => $arParams["HIDE_NOT_AVAILABLE"],
          "TEMPLATE_THEME" => $arParams["TEMPLATE_THEME"],
          'CONVERT_CURRENCY' => $arParams['CONVERT_CURRENCY'],
          'CURRENCY_ID' => $arParams['CURRENCY_ID'],
          "SEF_MODE" => $arParams["SEF_MODE"],
          "PAGER_PARAMS_NAME" => $arParams["PAGER_PARAMS_NAME"],
          "SEF_RULE" => '/catalog/filter/#SMART_FILTER_PATH#/apply/',
          "SMART_FILTER_PATH" => $arResult["VARIABLES"]["SMART_FILTER_PATH"],
          'SHOW_ALL_WO_SECTION'=>'Y',
        ),
        $component,
        array('HIDE_ICONS' => 'Y')
      );
    ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question