I
I
Irek Sitdikov2016-06-27 13:46:14
1C-Bitrix
Irek Sitdikov, 2016-06-27 13:46:14

How to add a highload field to a block in Bitrix?

I added a new HighLoad block using the Bitrix API, how can I add the name of a new field for it?
The following code swears that the UF_NAME field is not in the HighLoad block.

\Bitrix\Main\Loader::IncludeModule('highloadblock');
  $data = array(
    'NAME' => 'Statuses',
    'TABLE_NAME' => 'ib_statuses'
  );         
  $result = \Bitrix\Highloadblock\HighloadBlockTable::add($data);
  
  if ($result->isSuccess()) {
    
    $HLBId = $result->getId();
  
    $hlblock           = \Bitrix\Highloadblock\HighloadBlockTable::getById( $HLBId )->fetch(); // получаем объект HL блока
    $entity            = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity( $hlblock );  // получаем рабочую сущность
    $entity_data_class = $entity->getDataClass(); // получаем экземпляр класса
    $entity_table_name = $hlblock['TABLE_NAME']; // присваиваем переменной название HL таблицы
    $sTableID          = 'tbl_'.$entity_table_name; // добавляем префикс и окончательно формируем название
  
    $arData = Array(
      0 => Array(
        'UF_NAME' => 'Новая'
      ),
      1 => Array(
        'UF_NAME' => 'На экспертизе'
      ),
      2 => Array(
        'UF_NAME' => 'У автора на доработке'
      ),
      3 => Array(
        'UF_NAME' => 'В реализации'
      )
    );
    foreach ($arData as $item){
      $result = $entity_data_class::add($item);
    }
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Maksimenko, 2016-06-27
@sitdirek

https://www.olegpro.ru/post/skripty_migraciy_dlya_... an example of creating an hl-block, as well as fields for it

R
Ruslan Saifullin, 2016-06-27
@Shapito27

thisis-blog.ru/highload-blok-s-aktualnymi-svojstva...
thisis-blog.ru/elementi-highload-bloka

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question