Skip to content

Instantly share code, notes, and snippets.

@Isa3v
Last active February 24, 2023 10:19
Show Gist options
  • Save Isa3v/4a0cc6fcc3faa75964c88ae988131424 to your computer and use it in GitHub Desktop.
Save Isa3v/4a0cc6fcc3faa75964c88ae988131424 to your computer and use it in GitHub Desktop.
Bitrix ORM - Быстрые наброски для получения элементов и разделов
<?
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();
<?
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