L
L
leracoder2020-05-22 11:59:52
1C-Bitrix
leracoder, 2020-05-22 11:59:52

Is it possible to display infoblock elements using the section name?

Beginner developer in Bitrix. Faced with a problem:
The infoblock has the following structure:
- section name 1 - char. code 1
- element 1
- element 2
- ...
- section name 2 - char. code 2
....

Initially, each section was given a character code, and I used the filter:
"SECTION_CODE" => section code. to display elements from the desired section.

Code
$arFilter = Array(
"IBLOCK_ID"=>29,
"ACTIVE"=>"Y",
"SECTION_CODE" => section code
"INCLUDE_SUBSECTIONS" => "Y",
"PROPERTY_CATEGORY_IMG",
);

$fields = Array('NAME'
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $fields);

Is it possible to display infoblock elements by filtering by section name?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-05-22
@PetrPo

The idea, of course, is so-so, but if you really need it

$iblockId = 2;

$arElements = \Bitrix\Iblock\ElementTable::getList([
    'select' => ['IBLOCK_ID', 'ID', 'NAME', 'SECTION.NAME'],
    'filter' => ['IBLOCK_ID' => $iblockId, 'SECTION.NAME' => 'Мягкая мебель'],
    'order' => [],
    'runtime' => [
        'SECTION' => [
            'data_type' => '\Bitrix\Iblock\Section',
            'reference' => ['this.IBLOCK_SECTION_ID' => 'ref.ID'],
            'join_type' => 'LEFT'
        ]
    ]
])->fetchAll();

print_r($arElements);

Change $iblockId, adjust the filter to suit yours

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question