Skip to content

Instantly share code, notes, and snippets.

@demoriz
Last active August 8, 2023 13:03
Show Gist options
  • Save demoriz/244dbb218a30315ddb1d3e13de90aeea to your computer and use it in GitHub Desktop.
Save demoriz/244dbb218a30315ddb1d3e13de90aeea to your computer and use it in GitHub Desktop.
[iblock] работа с инфоблоком на d7 #bitrix #d7
<?php
$iblock = \Bitrix\Iblock\Iblock::wakeUp($intIblockId);
$strIblockClass = $iblock->getEntityDataClass();
// элемент
$arParams = array(
'select' => array('ID', 'NAME', 'ARTNUMBER_' => 'ARTNUMBER', 'MORE_PHOTO.FILE')
);
$arElement = \Bitrix\Iblock\Elements\ElementCatalogTable::getByPrimary($intElementId, $arParams)->fetch();
$element = \Bitrix\Iblock\Elements\ElementCatalogTable::getByPrimary($intElementId, $arParams)->fetchObject();
// список элементов
$arParams = array(
'select' => array('ID', 'NAME', 'ARTNUMBER_' => 'ARTNUMBER', 'NEWPRODUCT.ITEM'),
'filter' => array('=ACTIVE' => 'Y'),
'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(*)')),
'cache' => array('ttl' => 3600)
);
$arElements = \Bitrix\Iblock\Elements\ElementCatalogTable::getList($arParams)->fetchAll();
$elements = \Bitrix\Iblock\Elements\ElementCatalogTable::getList($arParams)->fetchCollection();
// раздел
$arSection = \Bitrix\Iblock\SectionTable::getById(123)->fetch();
// список разделов
$arParams = array(
'select' => array('ID', 'NAME'),
'filter' => array('IBLOCK_ID' => 1, 'DEPTH_LEVEL' => 1)
);
$arSections = \Bitrix\Iblock\SectionTable::getList($arParams)->fetchAll();
$section = \Bitrix\Iblock\Model\Section::compileEntityByIblock(1);
$dbSection = $section::getList($arParams);
while($arSection = $dbSection->Fetch())
// https://mrcappuccino.ru/blog/post/iblock-elements-bitrix-d7
// https://estrin.pw/bitrix-d7-snippets/s/iblock-sectiontable/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment