php 脚本为导入对象mcity创建xml文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 脚本为导入对象mcity创建xml文件相关的知识,希望对你有一定的参考价值。
<?
ini_set("display_errors",1);
error_reporting(E_ALL);
$_SERVER["DOCUMENT_ROOT"] = "/domains/brcrm.brightrich.ru";
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
require_once $_SERVER["DOCUMENT_ROOT"].'/bitrix/modules/main/include/prolog_before.php';
// require_once $_SERVER['DOCUMENT_ROOT'].'/xml-make/fn.php';
$debug = 1;
$result = array();
//CModule::IncludeModule('iblock');
$arFilter = array(
'IBLOCK_ID'=>52,
'ACTIVE'=>'Y',
'ID' => array(1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 10207, 39548, 60332),
'PROPERTY_TYPEOBJ'=>array(369)
);
$select = array('ID','IBLOCK_ID','NAME','CODE','PREVIEW_PICTURE','ACTIVE');
$res = CIBlockElement::GetList($sort, $arFilter, false, false, $select);
while($ob = $res->GetNextElement())
{
$el = $ob->GetFields();
$arProps = $ob->GetProperties();
$arProps = disable_elements($arProps, array('ACTIVEBR', 'ACTIVECREMAP', 'ELIDEANALYTIC', 'TEOREMAID', 'REESTRCODE', 'LOCATION', 'DISTRICT', 'DIRECTION', 'ADTOWN', 'ENADTOWN', 'SIZEMIN','SIZEMAX','ID','SITEURL','CONTACTLINK',
'LINKSITE', 'BRPHOTOS','BRPHOTOSIN', 'CREPHOTOS', 'CREPHOTOSIN', 'PLANPIC', 'BRLEGPERS', 'BRCONTRACTNUM',
'BRCONTRACTFILE', 'BRLEGDATEOFF', 'BRCOMMISSION', 'BRCOMMISSIONY', 'BREMAILVOTE', 'CRELEGPERS', 'CRECONTRACTNUM',
'CRECONTRACTFILE', 'CRELEGDATEOFF', 'CRECOMMISSION', 'CRECOMMISSIONY', 'CREEMAILVOTE', 'CRESPEAKVOTE', 'AMOID',
'UPROMO','ID655','BRSALECOMMISSION','CRESALECOMMISSION','UNSETPARSER','CREREKCONTRACTNUM','CREREKCONTRACTFILE','CREREKDATEOFF', 'CITY','DATEUPDATE'
));
$arProps = $arProps['CONFIRM'];
//na($el);
$card_props = $pathPic = array();
foreach($arProps as $code=>$p)
{
//na($p['VALUE']);
if($p['PROPERTY_TYPE'] == 'S' OR $p['PROPERTY_TYPE'] == 'N' OR $p['PROPERTY_TYPE'] == 'E')
{
$card_props[$code] = array(
'VALUE' => $p['VALUE'],
'DESCRIPTION' => $p['DESCRIPTION'],
);
}
elseif($p['PROPERTY_TYPE'] == 'L')
{
//na($p);
$card_props[$code] = array(
'VALUE' => $p['VALUE'],
'DESCRIPTION' => $p['DESCRIPTION'],
);
}
if($code == 'ENNAME')
{
if (!$p['VALUE'] OR !sizeof($p['VALUE'])) {
unset($card_props['ENNAME']);
}
}
}
$result[] = array(
'NAME' => $el['NAME'],
'ID' => $el['ID'],
'ACTIVE' => $el['ACTIVE'],
'SORT' => $el['SORT'],
// 'DETAIL_PICTURE' => CFile::GetPath($el['PREVIEW_PICTURE']),
'props' => $card_props,
);
}
if($debug != 1) {
na($result);
}
else {
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$root = $doc->createElement('cards');
$root = $doc->appendChild($root);
foreach($result as $lvl) {
$thumb = $doc->createElement('offer');
$thumb = $root->appendChild($thumb);
foreach($lvl as $key=>$value)
{
$em = $doc->createElement($key);
$list = $thumb->appendChild($em);
//na($value);
if($key == 'photo') {
}
else
{
if(is_array($value))
{
foreach ($value as $sub_code=>$v)
{
//na($v);
if(is_array($v['VALUE']))
{
$em2 = $doc->createElement($sub_code);
$list2 = $em->appendChild($em2);
foreach($v as $send_code=>$v_send)
{
if(is_array($v_send))
{
//na($send_code);
$em3 = $doc->createElement($send_code);
$list3 = $em2->appendChild($em3);
foreach ($v_send as $multi_send)
{
$em4 = $doc->createElement($send_code);
$list4 = $em3->appendChild($em4);
$text = $doc->createTextNode($multi_send);
$em4->appendChild($text);
}
}
else
{
$em3 = $doc->createElement($send_code);
$list3 = $em2->appendChild($em3);
$text = $doc->createTextNode($v_send);
$em3->appendChild($text);
}
}
}
else
{
$em2 = $doc->createElement($sub_code);
$list2 = $em->appendChild($em2);
foreach($v as $send_code=>$v_send) {
$em3 = $doc->createElement($send_code);
$list3 = $em2->appendChild($em3);
$text = $doc->createTextNode($v_send);
$em3->appendChild($text);
}
}
}
}
else {
//na($value);
$text = $doc->createTextNode($value);
$em->appendChild($text);
}
}
}
}
$doc->normalize();
$doc->save($_SERVER['DOCUMENT_ROOT'].'/upload/xml/feed_mskcity_card.xml');
}
require_once $_SERVER["DOCUMENT_ROOT"].'/bitrix/modules/main/include/epilog_after.php';
以上是关于php 脚本为导入对象mcity创建xml文件的主要内容,如果未能解决你的问题,请参考以下文章
使用 php 脚本将 pimcore 中的现有数据对象导出到 XML 文件
Javascript:从从 XML 文件导入数据切换到从 JS 对象数组导入数据