A
A
anriko2020-07-02 22:21:26
1C-Bitrix
anriko, 2020-07-02 22:21:26

How to make one more field a field for sorting in the catalog one for the filter another for sections?

5efe32c4cd098990791617.png
I created a field in the admin panel in the section in additional fields, but how can I bind it to sorting?
5efe336f3b4ce961398184.png
how to add this field here I insert UF_SORT but it does not sort by it 5efecfa2615ef999181164.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-07-06
@anriko

Since the iblock module version 20.0.400, the CUSTOM_SECTION_SORT parameter has become available in the catalog.section.list component and it works - I checked it myself.
In versions of the module lower than specified in the documentation, this parameter will not work.
You can find it in the file /bitrix/components/bitrix/catalog.section.list/component.php

//ORDER BY
  $arSort = array(
    "left_margin"=>"asc",
  );

and replace it with the one in the new version
//ORDER BY
  $arSort = array();
  if (!empty($this->arParams['CUSTOM_SECTION_SORT']) && is_array($this->arParams['CUSTOM_SECTION_SORT']))
  {
    foreach ($this->arParams['CUSTOM_SECTION_SORT'] as $field => $value)
    {
      if (!is_string($value))
      {
        continue;
      }
      $field = strtoupper($field);
      if (isset($arSort[$field]))
      {
        continue;
      }
      if (!preg_match('/^(asc|desc|nulls)(,asc|,desc|,nulls)?$/i', $value))
      {
        continue;
      }
      $arSort[$field] = $value;
    }
    unset($field, $value);
  }

  if (empty($arSort))
  {
    $arSort = array(
      "LEFT_MARGIN" => "ASC",
    );
  }

well, add to the call parameters of the catalog.section.list component
$sectionListParams = array(
  //.......
  "CUSTOM_SECTION_SORT" => array("UF_SORT" => "ASC")
);

In a beautiful way, of course, you need to add a sorting selection parameter to the catalog component and pass it to catalog.section.list

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question