Z
Z
Zzpro2022-01-12 16:49:52
1C-Bitrix
Zzpro, 2022-01-12 16:49:52

How to overcome 404 error when filtering at the root of a directory?

Please help me solve the problem, filtering in sections by ajax works without any problems, and at the root it gives a 404 error in the

GET console https://site.ru/catalog/filter/min_price-to-31/apply/ 404

And if you go to this page, everything works fine.

catalog.smart.filter:

$APPLICATION->IncludeComponent("bitrix:catalog.smart.filter", "bootstrap_v4", array(
              "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
              "IBLOCK_ID" => $arParams["IBLOCK_ID"],
              "SECTION_ID" => 0,
              "FILTER_NAME" => $arParams["FILTER_NAME"],
              "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" => "N",
              "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"],
                    "SEF_RULE" => '/catalog/filter/#SMART_FILTER_PATH#/apply/',
                    "SMART_FILTER_PATH" => $_REQUEST["SMART_FILTER_PATH"],
                    'SHOW_ALL_WO_SECTION'=>'Y',
              'SHOW_ALL_WO_SECTION'=> $SHOW_ALL_WO_SECTION,
              "PAGER_PARAMS_NAME" => $arParams["PAGER_PARAMS_NAME"],
              "INSTANT_RELOAD" => $arParams["INSTANT_RELOAD"],
            ),
            $component,
            array('HIDE_ICONS' => 'Y')
          );


urlrewrite.php
12 => 
  array (
    'CONDITION' => '#^/catalog/#',
    'RULE' => '',
    'ID' => 'bitrix:catalog',
    'PATH' => '/catalog/index.php',
    'SORT' => 100,
  ), 
 11 => 
  array (
    'CONDITION' => '#^/catalog/filter/(.+?)/apply/#',
    'RULE' => 'SMART_FILTER_PATH=$1&',
    'ID' => '',
    'PATH' => '/catalog/index.php',
    'SORT' => 99,
  ),


filter script.js changed to filter by ajax
//if (modef.style.display === 'none')
                //{
                    modef.style.display = 'inline-block';
                //}
    $.get(
        BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL), 
        function (data) {
            $('.col.ff').html($(data).find('.col.ff').html());
        }
    );

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zzpro, 2022-01-13
@Zzpro

Turned off the CNC everything works.
Answer from bitrix support:
Please try to disable the CNC. Is the filtering correct?
The fact is that now the CNC in the smart filter will really not work if the section is not transferred there.
We have a request for this revision, but we would like to make sure that your reason is in the CNC.
How not to be clear now, the strangest thing is that the url works when accessing it, but not using ajax.
I found a solution on my own https://ftask.ru/2020/04/24/bitrix-if-smart-filt...

E
Eugene, 2022-01-12
@udjin123

At a glance, I see that in urlrewrite.php requests will not reach the next rule, since the first one also corresponds to requests of the form /catalog/filter/...... And also keep in mind that Bitrix sorts it when saving according to some kind of stupid logic .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question