Documentation

SetElementSection

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 bindings to sections.

Description and parameters

CIBlockElement::SetElementSection(
 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.

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.
6.5.7
bRightsIBlockIblock (ID) for an element. Parameter is required in case of enabled extended access permissions; otherwise its optional.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

Example


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