Skip to content

Instantly share code, notes, and snippets.

@demoriz
Last active March 5, 2024 12:39
Show Gist options
  • Save demoriz/3ca6275e7a33c535d686f51aa0be6c43 to your computer and use it in GitHub Desktop.
Save demoriz/3ca6275e7a33c535d686f51aa0be6c43 to your computer and use it in GitHub Desktop.
bitrix d7 'highload element add'
<?php
use Bitrix\Highloadblock\HighloadBlockTable;
use Bitrix\Main\Loader;
Loader::includeModule('highloadblock');
// comment
// $intIblockID = 96;
// $arHLBlock = HighloadBlockTable::getById($intIblockID)->fetch();
$arHLBlock = HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => 'b_hlbd_bla_bla')))->fetch();
$entity = HighloadBlockTable::compileEntity($arHLBlock);
$strEntityDataClass = $entity->getDataClass();
$arData = array(
'UF_FIELD' => 'VALUE'
);
$result = $strEntityDataClass::add($arData);
if ($result->isSuccess()) {
$intID = $result->getId();
echo $intID;
} else {
echo 'error: ' . $result->getErrorMessages();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment