I
I
IliaMal2020-08-13 06:11:56
1C-Bitrix
IliaMal, 2020-08-13 06:11:56

How to display NAME properties in a non-XML_ID in a smart filter in CNC?

Hello.

We set it up in a smart CNC filter, but because of that, in our product properties, XML_ID is set by default in the url, we get something like /catalog/platya/filter/dlina_izdeliya-is-b012a3ad-eee1-11e8-a9a8-0cc47adb18fb/apply/
This entry is not allowed call CNC.
We cannot rewrite the XML_ID, our goods are imported from 1s, the unloading will fail due to the replacement of the XML_ID.

Apparently, it is necessary to customize the catalog.smart.filter and catalog.section components so that the filtering is carried out by the property name, and not by XML_ID.

Has anyone solved similar problems? Can you share your experience, where to edit?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Alexandrov, 2020-08-13
@alexyarik

https://marketplace.1c-bitrix.ru/solutions/sotbit....
according to the same principle as they do
https://it-svalka.ru/razrabotka/tonkaya-nastroyka-...
How to make SEO data for smart filter?

P
PetrPo, 2020-08-13
@PetrPo

Customize catalog.smart.filter class.php file
1. In makeSmartUrl method find

//Numbers && calendar == ranges
        if (
          $arItem["PROPERTY_TYPE"] == "N"
          || $arItem["DISPLAY_TYPE"] == "U"
        )
        {
          if (strlen($arItem["VALUES"]["MIN"]["HTML_VALUE"]) > 0)
            $smartPart["from"] = $arItem["VALUES"]["MIN"]["HTML_VALUE"];
          if (strlen($arItem["VALUES"]["MAX"]["HTML_VALUE"]) > 0)
            $smartPart["to"] = $arItem["VALUES"]["MAX"]["HTML_VALUE"];
        }
        else
        {
          foreach($arItem["VALUES"] as $key => $ar)
          {
            if (
              (
                $ar["CHECKED"]
                || $ar["CONTROL_ID"] === $checkedControlId
              )
              && strlen($ar["URL_ID"])
            )
            {
              $smartPart[] = $ar["URL_ID"];
            }
          }
        }

in else replace two $ar["URL_ID"] with $ar["VALUE"]
2. Replace searchValue method with
public function searchValue($item, $lookupValue)
  {
    $error = "";
    $searchValue = \Bitrix\Main\Text\Encoding::convertEncoding($lookupValue, LANG_CHARSET, "utf-8", $error);
    if (!$error)
    {
      $encodedValue = rawurlencode($searchValue);
      foreach($item as $itemId => $arValue)
      {
        $convertValue = \Bitrix\Main\Text\Encoding::convertEncoding($arValue['VALUE'], LANG_CHARSET, "utf-8", $error);
        if ($encodedValue === rawurlencode($convertValue))
          return $itemId;
      }
    }
    return false;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question