Код |
---|
//сортировка разделов по названию function updateCatalogSort() { $CATALOG_ID = 49; \Bitrix\Main\Loader::includeModule('iblock'); $arSort = Array("NAME" => "ASC"); $bs = new CIBlockSection; $counter = 1000; $step = 100; $arFilter = Array( "IBLOCK_ID" => array($CATALOG_ID), ); $arSelect = Array("ID", "SORT"); $dbRes = CIBlockSection::GetList($arSort, $arFilter, false, $arSelect, false); $isUpdated = false; while ($row = $dbRes->Fetch()) { if ($counter != $row['SORT']) { $bs->Update($row["ID"], Array("SORT" => $counter), false); if (!$isUpdated) $isUpdated = true; } $counter += $step; } if ($isUpdated) CIBlockSection::ReSort($CATALOG_ID); return 'updateCustomCatalogSort();'; } |
Можно повесить на событие на выгрузку.