Use of this method is not recommended, because it's a service method, although a public one. You need to use the method [link=90665]CIBlockElement::Update[/link] to pass keys IBLOCK_SECTION_ID and IBLOCK_SECTION.

Description and parameters

 int ID,
 array arSections,
bool bNew = false,
int bRightsIBlock = 0

Method binds an iblock element to groups. Non-static method. Element update time doesn't change when using the method.

Executed method changes main section ID to the lowest of passed array of group IDs. However, this is done only in case when iblock doesn't have enabled parameter Enable to select main section for binding. Main section isn't updated for iblocks with such setting enabled

Call parameters

ParameterDescription Available from version
ID Element code (ID).
arSections Array with group codes to which specified element belongs. When passed as empty, element will be "unbound" from all groups.
bNewOptional. If this is a new element or an element that doesn;t have any bindings, you can set this parameter value as true. This allows saving time spent for one query.

This parameter is used for optimization only, when it's known that element isn't bound to anything.
bRightsIBlockIblock (ID) for an element. Parameter is required in case of enabled extended access permissions; otherwise its optional.11.0.5
sectionIdSection ID deemed as the main section. (int or null). Optional parameter.11.0.5

Starting from Iblock module version 15.0.1, a new faceted (i. e. predefined) search by catalog products. After using the function CIBlockElement::SetElementSection() you need to perform the following:

PropertyIndex\Manager::updateElementIndex($iblockId, $elementId);

See Also


$ID = 18;  // element ID
$arSects = array(1, 5, 7); // array of section ID's
CIBlockElement::SetElementSection($ID, $arSects);
© «Bitrix24», 2001-2023