Skip to content

Instantly share code, notes, and snippets.

@Pum-purum
Created October 16, 2018 07:02
Show Gist options
  • Save Pum-purum/3be4072b4c827398ea790c13f509853f to your computer and use it in GitHub Desktop.
Save Pum-purum/3be4072b4c827398ea790c13f509853f to your computer and use it in GitHub Desktop.
Получить ID инфоблока по его коду
function GetIBlockIDByCode($code, $type = '')
{
CModule::IncludeModule("iblock");
$arrFilter = array(
'ACTIVE' => 'Y',
'CODE' => $code,
'SITE_ID' => "s1",
);
if ($type) {
$arrFilter['TYPE'] = $type;
}
$res = CIBlock::GetList(Array("SORT" => "ASC"), $arrFilter, false);
$arIBlockId = "";
if ($ar_res = $res->Fetch()) {
$arIBlockId = $ar_res["ID"];
}
return $arIBlockId;
}
@AlekseiKhilko
Copy link

    $files = [];
    $res = FileTable::getList(array(
        'select' => array(
            'FILE_ID'
        ),
        'filter' => array(
            'ENTITY_ID' => $entityId,
            '=ENTITY_TYPE' => $entityType
        )
    ));
    while ($row = $res->fetch())
    {
        $files[] = $row['FILE_ID'];
    }
    return $files;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment