Answer the question
In order to leave comments, you need to log in
How to programmatically assign the main section to the infoblock elements without resetting all the others?
On the site, the goods belong to several categories at the same time, and the task was to specify the root category as the main section. Tried through update (), specifying the desired section in the "IBLOCK_SECTION_ID" parameter, does not work, only the selected section remains, the rest of the bindings are reset. Has anyone faced such a task? How did they decide?
Answer the question
In order to leave comments, you need to log in
If you look at the Add and Update methods of the CIblockElement class, the update is performed by the following code:
if(array_key_exists("IBLOCK_SECTION_ID", $arFields))
{
if (!array_key_exists("IBLOCK_SECTION", $arFields))
{
$arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]);
}
elseif (is_array($arFields["IBLOCK_SECTION"]) && !in_array($arFields["IBLOCK_SECTION_ID"], $arFields["IBLOCK_SECTION"]))
{
unset($arFields["IBLOCK_SECTION_ID"]);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question