Answer the question
In order to leave comments, you need to log in
How to get the root section of an infoblock element?
Hello
There is an element ID. There are several levels of nesting in the infoblock. How to get the root folder ID of this element?
If we use CIBlockElement::GetByID($id) , then we get the folder in which this element is nested, and I need the parent of this folder.
Answer the question
In order to leave comments, you need to log in
CIblockElement receives an element, but not a section, and an element cannot be nested within an element - only within a section (not just one).
If you are interested in all root elements (i.e. elements that do not have a section to bind to), then you need to use CIblockElement::getList() and get all products with SECTION_ID = false, "" or 0. Read the documentation on this topic : https://dev.1c-bitrix.ru/api_help/iblock/classes/c...
If it turns out that you have 1 root section in the infoblock and you need to get its elements, then first you need to get it ID through CIblockSection::getList() and only then in SECTION_ID through CIblockelement::getList get all its elements (INCLUDE_SUBSECTIONS = N!). Read the documentation on this topic:https://dev.1c-bitrix.ru/api_help/iblock/classes/c...
I recently encountered a similar problem, perhaps someone will find this solution useful:
How to get the root section of an infoblock element?
There is an element ID. There are several levels of nesting in the infoblock. How to get the root folder ID of this element?
select
s.*
from b_iblock_section_element l
join b_iblock_section s
on s.ID = l.IBLOCK_SECTION_ID
where
l.IBLOCK_ELEMENT_ID = $id
and s.DEPTH_LEVEL = 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question