Last active
February 24, 2023 10:19
-
-
Save Isa3v/4a0cc6fcc3faa75964c88ae988131424 to your computer and use it in GitHub Desktop.
Bitrix ORM - Быстрые наброски для получения элементов и разделов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
use \Bitrix\Main\Loader; | |
use \Bitrix\Iblock\Iblock; | |
Loader::includeModule("iblock"); | |
$result = []; | |
$iblockId = 1; | |
$iblockProjects = \Bitrix\Iblock\Iblock::wakeUp($iblockId); | |
$iblockProjectsEntity = $iblockProjects->getEntityDataClass(); | |
// Или | |
$items = \Bitrix\Iblock\Elements\Element{CODE_API}Table::query() | |
->where('SECTION.ID', 64) | |
->addSelect('ID') | |
->fetchCollection(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
use \Bitrix\Main\Loader; | |
use \Bitrix\Iblock\Model\Section; | |
Loader::includeModule("iblock"); | |
$result = []; | |
$iblockId = 2; | |
$entitySection = \Bitrix\Iblock\Model\Section::compileEntityByIblock($iblockId); | |
// Фильтр | |
$filterProject = [ | |
'IBLOCK_ID' => $iblockId, | |
'ACTIVE' => 'Y', | |
]; | |
$sections = $entitySection::getList([ | |
'filter' => $filterProject, | |
'select' => [ | |
'ID', | |
'NAME', | |
'PICTURE', | |
'DESCRIPTION', | |
'UF_TYPE', | |
'UF_SUBTITLE', | |
], | |
])->fetchCollection(); | |
foreach ($sections as $section) { | |
$sectionId = $section->get('ID'); // Значение | |
$arSection = $section->collectValues(); // Обьект в массив | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment