Answer the question
In order to leave comments, you need to log in
How to re-sort the properties of the Bitrix element and pass them to the array further?
There is an element, it has properties.
One of the properties is the new property sort order.
I am reordering the array in result_modifier.php
//формирую новый массив с новыми данными для сортировки
foreach ($arResult["DISPLAY_PROPERTIES"] as $key => $array_sort) {
if($array_sort['CODE'] == 'AD_SORT_SORT') $array_sort_value = array($array_sort['VALUE']);
}
// пересортировываю массив
foreach ($array_sort_value['0'] as $key => $value) {
$arrr = explode("=",$value);
$sort[trim($arrr['0'])] = $arrr['1'];
}
//сортирую по возрастанию
asort($sort);
print_r($sort);
$arResult["DISPLAY_PROPERTIES"] = array_map(
function ($itm) use ($sort) {
$id = $itm['ID'];
if (isset($sort[$id])) {
$itm['SORT'] = $sort[$id];
}
return $itm;
},
$arResult["DISPLAY_PROPERTIES"]
);?>
Array ( [185] => 300 [173] => 350 [172] => 500 )
Array ( [172] => 500 [185] => 300 [173] => 350 )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question