Answer the question
In order to leave comments, you need to log in
How to make an alternative CNC smart filter?
Hello everybody!
I want to make an alternative CNC smart filter, so that instead of "site.ru/catalog/filter/brand-is-makita/apply/" there is a beautiful "site.ru/catalog/makita/" tell me how to implement it. Perhaps someone has already done this and will throw a thought in which direction to pick. I can roughly imagine the implementation options, for example, changing the url, but in theory it should work out a 301 redirect, or maybe it shouldn’t. In any case, I appeal to you more experienced colleagues.
Answer the question
In order to leave comments, you need to log in
Remove filter and apply Replace
the line in the bitrix:catalog component with :
"smart_filter" => "#SECTION_CODE_PATH#/#SMART_FILTER_PATH#/",
<?
$res = CIBlockSection::GetByID($arCurSection['ID']);
if($ar_res = $res->GetNext())
$url = "/catalog/".$ar_res[CODE]."/#SMART_FILTER_PATH#/";
$APPLICATION->IncludeComponent("bitrix:catalog.smart.filter", "bootstrap_v4", array(
"CACHE_GROUPS" => "N", // Учитывать права доступа
"CACHE_TIME" => "3600", // Время кеширования (сек.)
"CACHE_TYPE" => "A", // Тип кеширования
"COMPOSITE_FRAME_MODE" => "N",
"COMPOSITE_FRAME_TYPE" => "AUTO",
"CONVERT_CURRENCY" => "N", // Показывать цены в одной валюте
"DISPLAY_ELEMENT_COUNT" => "N", // Показывать количество
"FILTER_NAME" => "arrFilter", // Имя выходящего массива для фильтрации
"FILTER_VIEW_MODE" => "vertical",
"HIDE_NOT_AVAILABLE" => "Y", // Не отображать товары, которых нет на складах
"IBLOCK_ID" => $arParams["IBLOCK_ID"], // Инфоблок
"IBLOCK_TYPE" => "catalog", // Тип инфоблока
"PAGER_PARAMS_NAME" => "arrPager",
"SAVE_IN_SESSION" => "N", // Сохранять установки фильтра в сессии пользователя
"SECTION_CODE" => "", // Код раздела
"SECTION_DESCRIPTION" => "-", // Описание
"SECTION_ID" => $arCurSection['ID'], // ID раздела инфоблока
"SECTION_TITLE" => "-", // Заголовок
"SEF_MODE" => "Y", // Включить поддержку ЧПУ
"TEMPLATE_THEME" => "blue", // Цветовая тема
"XML_EXPORT" => "N", // Включить поддержку Яндекс Островов
"COMPONENT_TEMPLATE" => "",
"POPUP_POSITION" => "left",
"SECTION_CODE_PATH" => "", // Путь из символьных кодов раздела
"SEF_RULE" => $url, // Правило для обработки
"SMART_FILTER_PATH" => $_REQUEST["SMART_FILTER_PATH"], // Блок ЧПУ умного фильтра
"SHOW_ALL_WO_SECTION" => "Y",
"PRICE_CODE" => "", // Тип цены
"PREFILTER_NAME" => "smartPreFilter", // Допфильтрация элементов
),
false);
?>
<?php
$arUrlRewrite=array (
1 =>
array (
'CONDITION' => '#^/catalog/([a-z0-9_\\-\\/]+)/#',
'RULE' => 'SMART_FILTER_PATH=$1&',
'ID' => '',
'PATH' => '/catalog/index.php',
'SORT' => 100,
),
2 =>
array (
'CONDITION' => '#^/catalog/\\??(.*)#',
'RULE' => 'SMART_FILTER_PATH=$1&$2',
'ID' => 'bitrix:catalog.smart.filter',
'PATH' => '/catalog/index.php',
'SORT' => 100,
),
3 =>
array (
'CONDITION' => '#^/catalog/#',
'RULE' => '',
'ID' => 'bitrix:catalog',
'PATH' => '/catalog/index.php',
'SORT' => 100,
)
);
$_REQUEST[SMART_FILTER_PATH] = str_replace("red/brown", "colors-is-brown-or-red/", $_REQUEST[SMART_FILTER_PATH]);
https://test.ru/catalog/pants/filter/color_ref-is-green/apply/
https://test.ru/catalog/pants/green/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question