Instantly share code, notes, and snippets.

Embed
What would you like to do?
Перенос пользовательских свойств 1С-Битрикс (с названиями + в обход тех которые уже есть)
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Export");
$arResult = array();
$rsData = CUserTypeEntity::GetList( array("ID"=>"ASC"), array("LANG" => "ru") );
while($arRes = $rsData->Fetch())
{
$ar_res = CUserTypeEntity::GetByID( $arRes['ID'] );
$arResult[] = $ar_res;
}
file_put_contents("users.json", json_encode($arResult));
?><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Import");
$arResult = array();
$rsData = CUserTypeEntity::GetList( array("ID"=>"ASC"), array() );
while($arRes = $rsData->Fetch())
{
$arResult[] = $arRes["FIELD_NAME"];
}
$arResultOld = json_decode(file_get_contents('users.json'), true);
foreach ($arResultOld as $key => $field)
{
unset($field['ID']);
if (!in_array($field['FIELD_NAME'], $arResult))
{
$ob = new CUserTypeEntity();
$FIELD_ID = $ob->Add($field);
echo "OK ADD - ".$field['FIELD_NAME']." ID -".$FIELD_ID."<br>";
}
}
?><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment