M
M
mills2021-08-10 07:31:11
1C-Bitrix
mills, 2021-08-10 07:31:11

How to prohibit changing sections of the 1C-Bitrix store when exchanging with 1c?

Hello!
Registered in init.php

AddEventHandler("iblock", "OnAfterIBlockElementAdd", "DropNAME");
AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", "DropNAME");
AddEventHandler("iblock", "OnBeforeIBlockElementUpdate","SaveInOldSection");

function DropNAME($arFields)
{    
    if ($_REQUEST['mode']=='import') {
        unset($arFields['NAME']);
        unset($arFields['ACTIVE']);
    }
}

function SaveInOldSection(&$arFields)
{
    if ($_REQUEST['mode']=='import') {
        $db_old_groups = CIBlockElement::GetElementGroups($arFields['ID'], true);
        while($ar_group = $db_old_groups->Fetch()) {
      if(!in_array($ar_group['ID'],$arFields['IBLOCK_SECTION'])) {
                $arFields['IBLOCK_SECTION'][]=$ar_group['ID'];
      }
        }
    }
}


But all the same, when exchanging with 1s, the location of the section changes, that is, it goes to the 2nd level, for example, and so on.
Bitrix version 20.0.950

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question