Last active
May 26, 2020 09:19
-
-
Save kuntashov/39b0c3c600e04c80336111c17cd112b8 to your computer and use it in GitHub Desktop.
Экспорт структуры товарного каталога для последующего импорта в настройку дерева каталогов в 1С
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CATALOG_IBLOCK_ID = 42; | |
//////////////////////////////////////////////////////////////////////////////// | |
CModule::IncludeModule("iblock"); | |
$arIBlock = CIBlock::GetByID($CATALOG_IBLOCK_ID)->Fetch(); | |
echo " | |
<?xml version=\"1.0\" encoding=\"UTF-8\"?> | |
<Разделы> | |
<Раздел> | |
<Ид>" . $arIBlock['XML_ID'] . "</Ид> | |
<Наименование>".$arIBlock['NAME']."</Наименование> | |
<ЭтоИнфоблок>true</ЭтоИнфоблок> | |
</Раздел> | |
"; | |
$arSort = array("left_margin"=>"asc", "name" => "asc"); | |
$arFilter = array("IBLOCK_ID"=> $CATALOG_IBLOCK_ID); | |
$rsSections = CIBlockSection::GetList( | |
$arSort, | |
$arFilter, | |
false, | |
array("ID","IBLOCK_SECTION_ID","NAME","XML_ID") | |
); | |
while ($arSection = $rsSections->Fetch()) { | |
$parent_id = $arSection['IBLOCK_SECTION_ID']; | |
echo " | |
<Раздел> | |
<Ид>" . $arSection['XML_ID'] . "</Ид> | |
<Наименование>".$arSection['NAME']."</Наименование> | |
<ЭтоИнфоблок>false</ЭтоИнфоблок> | |
". | |
($parent_id | |
? "<ИдРодителя>$parent_id</ИдРодителя>" | |
: "<ИдРодителя/>" | |
)." | |
<Номенклатура /> | |
</Раздел>"; | |
echo "\n"; | |
} | |
echo "</Разделы>\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment