Y
Y
Yuriy2019-12-04 15:36:21
1C-Bitrix
Yuriy, 2019-12-04 15:36:21

Bitrix\Highloadblock\HighloadBlockTable how to get block ID by name?

Actually the question is how to get the Highloadblock ID for the name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2019-12-04
@yous

$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(
        array("filter" => array(
            'TABLE_NAME' => 'НАЗВАНИЕ'
        ))
    )->fetch();
echo $hlblock['ID'];

R
ragnar_ok, 2019-12-05
@ragnar_ok

To solve the problem, you do not need to know the highloadblock's ID and use an additional wrapper function ( GetEntityDataClass($HL_BLOCK_ID )); in your example).
You can get what you need in one line:
It might be worth writing a wrapper function to catch exceptions thrown by the compileEntity method:

function compileEntity($entity): ?Base
    {
        try {
            return Highloadblock\HighloadBlockTable::compileEntity($entity);
        } catch (SystemException $systemException) {
            // что-нибудь
            return null;
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question