P
P
Pavel Sidorov2021-01-19 13:55:45
1C-Bitrix
Pavel Sidorov, 2021-01-19 13:55:45

How to change the value of the sort field. at an element of property of type the list?

There is a property of type list.
The property has values. The values ​​have a sorting field
How can I change this sorting through Bitrix api?

there is SetPropertyValueCode and SetPropertyValuesEx, but they change the value of the property. I need to change sorting of this value. I write like this, but not correctly.

Tell.

$arSelect = Array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "DATE_ACTIVE_FROM",);
      $arFilter = Array("IBLOCK_ID"=>2,  "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "PROPERTY_SEZON_VALUE"=>"Зима");
      $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);

      while($ob = $res->GetNextElement()){
      $arFields = $ob->GetFields(); 
      $arProps = $ob->GetProperties();

      if($arProps['SEZON']['VALUE'] == 'Зима'){
          //$arProps['SEZON']['VALUE_SORT'] = 100;
          
          $ELEMENT_ID = $arFields['ID'];  // код элемента
          $PROPERTY_CODE = $arProps['SEZON']['VALUE_SORT'];  // код свойства
          $PROPERTY_VALUE = 100;  // значение свойства
          CIBlockElement::SetPropertyValuesEx($arFields['ID'], false, array($arProps['SEZON']['VALUE_SORT'] => 100));
      }
          echo '<pre>'; 
            var_dump($arProps['SEZON']['VALUE_SORT']);
          echo '</pre>';

      }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-01-19
@pavel__sidorov

$valueId = 1;
$sort = 1;
CIBlockPropertyEnum::Update($valueId, ['SORT' => $sort]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question