W
W
Westoura2020-12-10 22:35:04
1C-Bitrix
Westoura, 2020-12-10 22:35:04

How to remove properties from a smart filter?

The online store has a brand page that displays products filtered by brand name. Products on this page can be filtered with a smart filter, but all properties that are pulled from the entire product catalog get inside it. For example, sorting products by brand remains available, although this property should not be displayed because the user is already on a page with filtered products. How to remove unnecessary properties from the smart filter on the brand page?

Products on the brand page are sorted using the "FILTER_NAME" => "arrFilterBrand" property. But this is not enough for a smart filter.

Catalog filtering by brand:

$brandName = $arResult["NAME"];
global $arrFilterBrand;
$arrFilterBrand = Array("PROPERTY_BRAND" => $arResult["ID"]);
?>


Smart filter code

<?$APPLICATION->IncludeComponent(
   "bitrix:catalog.smart.filter",
   Array(
      "CACHE_GROUPS" => "Y",
      "CACHE_TIME" => "36000000",
      "CACHE_TYPE" => "A",
      "CONVERT_CURRENCY" => "N",
      "DISPLAY_ELEMENT_COUNT" => "Y",
      "FILTER_NAME" => "arrFilterBrand",
      "FILTER_VIEW_MODE" => "vertical",
      "HIDE_NOT_AVAILABLE" => "Y",
      "IBLOCK_ID" => "20",
      "PAGER_PARAMS_NAME" => "arrPager",
      "PREFILTER_NAME" => "smartPreFilter",
      "PRICE_CODE" => array(),
      "SAVE_IN_SESSION" => "N",
      "SECTION_CODE" => "",
      "SECTION_DESCRIPTION" => "-",
      "SECTION_ID" => $_REQUEST["SECTION_ID"],
      "SECTION_TITLE" => "-",
      "SEF_MODE" => "N",
      "TEMPLATE_THEME" => "blue",
      "XML_EXPORT" => "N"
   )
);?>


Product list output:

<?$APPLICATION->IncludeComponent(
   "bitrix:catalog.section",
   Array(
      "FILTER_NAME" => "arrFilterBrand",
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2020-12-11
@Westoura

On the brand page, filtering by brand must be set through the PREFILTER_NAME smart filter parameter.
This parameter works in a similar way to FILTER_NAME.
the global array PREFILTER_NAME must be defined before catalog.smart.filter and the filter by brand must be passed to it. With it, the smart filter will first perform pre-filtering, which will not be displayed in the template. Other brands will disappear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question