F
F
fenix19902017-08-05 16:45:25
1C-Bitrix
fenix1990, 2017-08-05 16:45:25

How to get IBLOCK_SECTION_ID when creating a section via API?

We have the following standard code for adding a section through the bitrcs API delivered to the standard parser
foreach ($doc->find('.item') as $article)
{
$link = '';
$article = pq($article);
$number_1 = $article->find('div:eq(0).ovr>.code')->text();
$name = $article->find('div:eq(0).ovr>.name')->text();
$link = $article->find('div:eq(0).ovr>.name>.text')->attr('href');
$NAME = $number_1 ." ". $name;
$bs = new CIBlockSection;
$params = array
(
"max_len" => "100",
"change_case" => "L",
"
"use_google" => "false",
);
$CODE = CUtil::translit($NAME, "ru", $params);
$arFields = Array
(
"ACTIVE" => 'Y',
"CODE" => $CODE,
"IBLOCK_ID" => $IBLOCK_ID,
"NAME" => $NAME,
);
$bs->Add($arFields);
get_sections($link, $IBLOCK_SECTION_ID); // here's the catch, since I can't get $IBLOCK_SECTION_ID
}
function get_razdels($link, $IBLOCK_SECTION_ID)
{
$file = file_get_contents($link);
$doc = phpQuery::newDocument($file);
foreach ($doc->find('.item'
) as $article) { $article = pq($article);
$link = '';
$number_2 = $article->find('div:eq(0).linkover>.code>span')->text();
$name = $article->find('div:eq(0).linkover>.name>.text')->text();
$link = $article->find('div:eq(0).linkover>.name>.text')->attr('href');
$NAME = $number_2 ." ". $name;
$bs = new CIBlockSection;
$arFields = Array(
"ACTIVE" => "Y",
"IBLOCK_SECTION_ID" => $IBLOCK_SECTION_ID,
"CODE" => "catalog",
"IBLOCK_ID" => $IBLOCK_ID,
"NAME" => $NAME,
);
$CODE = CUtil:: translit($NAME, "ru", $params);
$arFields = Array
(
"ACTIVE" => 'Y',
"CODE" => $CODE,
"IBLOCK_ID" => $IBLOCK_ID,
"NAME" => $NAME,
);
$bs->Add($arFields);
}
how to get its IBLOCK_SECTION_ID?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fenix1990, 2017-08-05
@fenix1990

the issue was solved with "crutches" =)
$res = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $arParams["IBLOCK_ID"], 'CODE' => $section["CODE"], 'SITE_ID' => "s2"));
$section = $res->Fetch();
$section["ID"];

A
Artyom Luchnikov, 2017-08-05
@lu4nik

I understand you want to get the ID of the parent section? So it will not be in your case, because it is not set in the array of fields. Well, if it were given, then why receive it? He would already be famous.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question