Created
January 21, 2017 16:57
-
-
Save iredun/de4cdfd91c032d13471b13c2bf0897ab to your computer and use it in GitHub Desktop.
Перенос пользовательских свойств 1С-Битрикс (с названиями + в обход тех которые уже есть)
This file contains 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
<?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");?> |
This file contains 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
<?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