d0b41e26-f32b-11e4-821e-001a4d382000falsefalse00000000-0000-0000-0000-00000000000000000782
Билимбаевская, 16а
<ТипБлока xmlns="" xsi:type="CatalogRef.ТипыРекламныхБлоков">bc469c4f-6e2a-11e4-a640-5404a6b87cefТипБлока>
<НомерБлока xsi:type="xsd:string">0203НомерБлока>
<Район xmlns="" xsi:type="CatalogRef.Районы">7ee9aa05-9d57-11e4-af94-001fd05a9a5fРайон>
<Город xmlns="" xsi:type="CatalogRef.Города">9b79a739-6e20-11e4-a640-5404a6b87cefГород>
<Освещение xsi:type="xsd:boolean">falseОсвещение>
<Сторона xmlns="" xsi:type="CatalogRef.ВидыСторон">86e6ced2-2002-49b9-9aef-6dc3f08f92f9Сторона>
<Алкоголь xsi:type="xsd:boolean">falseАлкоголь>
<Табак xsi:type="xsd:boolean">falseТабак>
<ДатаУстановки xsi:type="xsd:dateTime">2015-04-30T00:00:00ДатаУстановки>
<ДатаУдаления xsi:type="xsd:dateTime">0001-01-01T00:00:00ДатаУдаления>
<Описание xsi:type="xsd:string">ПП через Расточную (слева)Описание>
d0b41e26-f32b-11e4-821e-001a4d382000
<Размер xmlns="" xsi:type="CatalogRef.РазмерыРекламныхБлоков">bc469c4e-6e2a-11e4-a640-5404a6b87cefРазмер>
<Координаты xsi:type="xsd:string">56.881473, 60.517850Координаты>
<Цена xsi:type="xsd:decimal">3300Цена>
РекламныеБлоки>
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/admin/1c_exchange.php");
?>
<?
define('BX_SESSION_ID_CHANGE', false);
define('BX_SKIP_POST_UNQUOTE', true);
define('NO_AGENT_CHECK', true);
define("STATISTIC_SKIP_ACTIVITY_CHECK", true);
if (isset($_REQUEST["type"]) && $_REQUEST["type"] == "crm")
{
define("ADMIN_SECTION", true);
}
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if($type=="sale")
{
$APPLICATION->IncludeComponent("bitrix:sale.export.1c", "", Array(
"SITE_LIST" => COption::GetOptionString("sale", "1C_SALE_SITE_LIST", ""),
"EXPORT_PAYED_ORDERS" => COption::GetOptionString("sale", "1C_EXPORT_PAYED_ORDERS", ""),
"EXPORT_ALLOW_DELIVERY_ORDERS" => COption::GetOptionString("sale", "1C_EXPORT_ALLOW_DELIVERY_ORDERS", ""),
"EXPORT_FINAL_ORDERS" => COption::GetOptionString("sale", "1C_EXPORT_FINAL_ORDERS", ""),
"CHANGE_STATUS_FROM_1C" => COption::GetOptionString("sale", "1C_CHANGE_STATUS_FROM_1C", ""),
"FINAL_STATUS_ON_DELIVERY" => COption::GetOptionString("sale", "1C_FINAL_STATUS_ON_DELIVERY", "F"),
"REPLACE_CURRENCY" => COption::GetOptionString("sale", "1C_REPLACE_CURRENCY", ""),
"GROUP_PERMISSIONS" => explode(",", COption::GetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", "1")),
"USE_ZIP" => COption::GetOptionString("sale", "1C_SALE_USE_ZIP", "Y"),
"INTERVAL" => COption::GetOptionString("sale", "1C_INTERVAL", 30),
"FILE_SIZE_LIMIT" => COption::GetOptionString("sale", "1C_FILE_SIZE_LIMIT", 200*1024),
"SITE_NEW_ORDERS" => COption::GetOptionString("sale", "1C_SITE_NEW_ORDERS", "s1"),
"IMPORT_NEW_ORDERS" => COption::GetOptionString("sale", "1C_IMPORT_NEW_ORDERS", "N"),
)
);
}
elseif($type=="crm")
{
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$orderId = intval($_POST["ORDER_ID"]);
$modifLabel = intval($_POST["MODIFICATION_LABEL"]);
$ZZZ = intval($_POST["ZZZ"]);
$IMPORT_SIZE = intval($_POST["IMPORT_SIZE"]);
$GZ_COMPRESSION_SUPPORTED = intval($_POST["GZ_COMPRESSION_SUPPORTED"]);
}
else
{
$orderId = intval($_GET["ORDER_ID"]);
$modifLabel = intval($_GET["MODIFICATION_LABEL"]);
$ZZZ = intval($_GET["ZZZ"]);
$IMPORT_SIZE = intval($_GET["IMPORT_SIZE"]);
$GZ_COMPRESSION_SUPPORTED = intval($_GET["GZ_COMPRESSION_SUPPORTED"]);
}
$APPLICATION->IncludeComponent("bitrix:sale.export.1c", "", Array(
"CRM_MODE" => "Y",
"ORDER_ID" => $orderId,
"MODIFICATION_LABEL" => $modifLabel,
"ZZZ" => $ZZZ,
"IMPORT_SIZE" => $IMPORT_SIZE,
"GZ_COMPRESSION_SUPPORTED" => $GZ_COMPRESSION_SUPPORTED,
"GROUP_PERMISSIONS" => explode(",", COption::GetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", "1")),
"REPLACE_CURRENCY" => COption::GetOptionString("sale", "1C_REPLACE_CURRENCY", ""),
"USE_ZIP" => "N",
)
);
}
elseif($type=="catalog")
{
$APPLICATION->IncludeComponent("bitrix:catalog.import.1c", "", Array(
"IBLOCK_TYPE" => COption::GetOptionString("catalog", "1C_IBLOCK_TYPE", "-"),
"SITE_LIST" => array(COption::GetOptionString("catalog", "1C_SITE_LIST", "-")),
"INTERVAL" => COption::GetOptionString("catalog", "1C_INTERVAL", "-"),
"GROUP_PERMISSIONS" => explode(",", COption::GetOptionString("catalog", "1C_GROUP_PERMISSIONS", "1")),
"GENERATE_PREVIEW" => COption::GetOptionString("catalog", "1C_GENERATE_PREVIEW", "Y"),
"PREVIEW_WIDTH" => COption::GetOptionString("catalog", "1C_PREVIEW_WIDTH", "100"),
"PREVIEW_HEIGHT" => COption::GetOptionString("catalog", "1C_PREVIEW_HEIGHT", "100"),
"DETAIL_RESIZE" => COption::GetOptionString("catalog", "1C_DETAIL_RESIZE", "Y"),
"DETAIL_WIDTH" => COption::GetOptionString("catalog", "1C_DETAIL_WIDTH", "300"),
"DETAIL_HEIGHT" => COption::GetOptionString("catalog", "1C_DETAIL_HEIGHT", "300"),
"ELEMENT_ACTION" => COption::GetOptionString("catalog", "1C_ELEMENT_ACTION", "D"),
"SECTION_ACTION" => COption::GetOptionString("catalog", "1C_SECTION_ACTION", "D"),
"FILE_SIZE_LIMIT" => COption::GetOptionString("catalog", "1C_FILE_SIZE_LIMIT", 200*1024),
"USE_CRC" => COption::GetOptionString("catalog", "1C_USE_CRC", "Y"),
"USE_ZIP" => COption::GetOptionString("catalog", "1C_USE_ZIP", "Y"),
"USE_OFFERS" => COption::GetOptionString("catalog", "1C_USE_OFFERS", "N"),
"FORCE_OFFERS" => COption::GetOptionString("catalog", "1C_FORCE_OFFERS", "N"),
"USE_IBLOCK_TYPE_ID" => COption::GetOptionString("catalog", "1C_USE_IBLOCK_TYPE_ID", "N"),
"USE_IBLOCK_PICTURE_SETTINGS" => COption::GetOptionString("catalog", "1C_USE_IBLOCK_PICTURE_SETTINGS", "N"),
"TRANSLIT_ON_ADD" => COption::GetOptionString("catalog", "1C_TRANSLIT_ON_ADD", "Y"),
"TRANSLIT_ON_UPDATE" => COption::GetOptionString("catalog", "1C_TRANSLIT_ON_UPDATE", "Y"),
"TRANSLIT_REPLACE_CHAR" => COption::GetOptionString("catalog", "1C_TRANSLIT_REPLACE_CHAR", "_"),
"SKIP_ROOT_SECTION" => COption::GetOptionString("catalog", "1C_SKIP_ROOT_SECTION", "N"),
"DISABLE_CHANGE_PRICE_NAME" => COption::GetOptionString("catalog", "1C_DISABLE_CHANGE_PRICE_NAME")
)
);
}
elseif($type=="reference")
{
$APPLICATION->IncludeComponent("bitrix:catalog.import.hl", "", Array(
"INTERVAL" => COption::GetOptionString("catalog", "1C_INTERVAL", "-"),
"GROUP_PERMISSIONS" => explode(",", COption::GetOptionString("catalog", "1C_GROUP_PERMISSIONS", "1")),
"FILE_SIZE_LIMIT" => COption::GetOptionString("catalog", "1C_FILE_SIZE_LIMIT", 200*1024),
"USE_CRC" => COption::GetOptionString("catalog", "1C_USE_CRC", "Y"),
"USE_ZIP" => COption::GetOptionString("catalog", "1C_USE_ZIP", "Y"),
)
);
}
elseif($type=="get_catalog")
{
$APPLICATION->IncludeComponent("bitrix:catalog.export.1c", "", Array(
"IBLOCK_ID" => COption::GetOptionString("catalog", "1CE_IBLOCK_ID", ""),
"INTERVAL" => COption::GetOptionString("catalog", "1CE_INTERVAL", "-"),
"ELEMENTS_PER_STEP" => COption::GetOptionString("catalog", "1CE_ELEMENTS_PER_STEP", 100),
"GROUP_PERMISSIONS" => explode(",", COption::GetOptionString("catalog", "1CE_GROUP_PERMISSIONS", "1")),
"USE_ZIP" => COption::GetOptionString("catalog", "1CE_USE_ZIP", "Y"),
)
);
}
elseif($type=="listen")
{
$APPLICATION->RestartBuffer();
CModule::IncludeModule('sale');
$timeLimit = 60;//1 minute
$startExecTime = time();
$max_execution_time = (intval(ini_get("max_execution_time")) * 0.75);
$max_execution_time = ($max_execution_time > $timeLimit )? $timeLimit:$max_execution_time;
if(CModule::IncludeModule("sale") && defined("CACHED_b_sale_order"))
{
while(!$CACHE_MANAGER->getImmediate(CACHED_b_sale_order, "sale_orders"))
{
usleep(1000);
if(intVal(time() - $startExecTime) > $max_execution_time)
{
break;
}
}
}
if($CACHE_MANAGER->getImmediate(CACHED_b_sale_order, "sale_orders"))
{
echo "success\n";
}
else
{
CHTTP::SetStatus("304 Not Modified");
}
}
else
{
$APPLICATION->RestartBuffer();
echo "failure\n";
echo "Unknown command type.";
}
?>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");?>
[2018-04-23 16:10:02 (YEKT)] START checkXML()
[2018-04-23 16:10:02 (YEKT)] Последний обработанный файл: MessageFor_30000000383.xml
[2018-04-23 16:10:02 (YEKT)] Путь к файлу выгрузки: /www/upload/1c_catalog/MessageFor_30000000384.xml
[2018-04-23 16:10:02 (YEKT)] START parseXML()
[2018-04-23 16:10:02 (YEKT)] BEFORE END parseXML: return self::addItems($arRes['ITEMS']
[2018-04-23 16:10:02 (YEKT)] START addItems
[2018-04-23 16:10:03 (YEKT)] Обновление существующего элемента "Велопарковка 0524"
...........................
[2018-04-23 16:18:10 (YEKT)] END deactivateItems: return true
[2018-04-23 16:18:11 (YEKT)] END checkXML(): return MA_CustomXMLimport::checkXML();
ОбменССайтом3238502e08e259-a845-11e4-b9f0-001fd05a9a5ffalsefalse00000000-0000-0000-0000-00000000000000000001
Синяя
<МестоСоздания>00000000-0000-0000-0000-000000000000МестоСоздания>
Категории>
.
.
.
35ecfcfa-75c7-11e7-a62b-001a4d382000falsefalse00000000-0000-0000-0000-00000000000000001901
Бакинских Комиссаров, 68/A
<ТипБлока xmlns="" xsi:type="CatalogRef.ТипыРекламныхБлоков">8b3f6c0b-6369-11e6-a3c0-001a4d382000ТипБлока>
<НомерБлока xsi:type="xsd:string">0769НомерБлока>
<Район xmlns="" xsi:type="CatalogRef.Районы">0bb76d6c-9a43-11e4-b9c6-001fd05a9a5fРайон>
<Город xmlns="" xsi:type="CatalogRef.Города">9b79a739-6e20-11e4-a640-5404a6b87cefГород>
<Освещение xsi:type="xsd:boolean">falseОсвещение>
<Сторона xmlns="" xsi:type="CatalogRef.ВидыСторон">86e6ced2-2002-49b9-9aef-6dc3f08f92f9Сторона>
<Алкоголь xsi:type="xsd:boolean">falseАлкоголь>
<Табак xsi:type="xsd:boolean">falseТабак>
<ДатаУстановки xsi:type="xsd:dateTime">2017-08-01T00:00:00ДатаУстановки>
<ДатаУдаления xsi:type="xsd:dateTime">0001-01-01T00:00:00ДатаУдаления>
<Описание xsi:type="xsd:string">ПП Бакинских КомиссаровОписание>
35ecfcfa-75c7-11e7-a62b-001a4d382000
<Размер xmlns="" xsi:type="CatalogRef.РазмерыРекламныхБлоков">8b3f6c0a-6369-11e6-a3c0-001a4d382000Размер>
<Координаты xsi:type="xsd:string">56.907220, 60.590651Координаты>
<Цена xsi:type="xsd:decimal">3300Цена>
РекламныеБлоки>
.
.
.
3d4ab3f9-5e71-4de1-b67c-266cfea7d3a0false00000007
B1
<Описание/>
ВидыСторон>
public static function parseXML($filePath) {
/*
Открываем файл, парсим как массив значений по строкам.
На выходе получаем структурированный массив рекламных блоков и св-в
После вызываем добавление элементов
*/
if (!CModule::IncludeModule('iblock')) die();
self::log('START parseXML()');
set_time_limit(0);
ignore_user_abort(true);
$data = implode("", file($filePath));
$work_dir = dirname($filePath);
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
// Get vals
$arRes = array();
$arRawItems = array();
$arRawProps = array();
$arPrices = array();
// return $values;
foreach ($values as $rowIterator => $arRow) {
$CUR_LVL = '';
$CUR_ITEM = '';
$arRow['tag'] = str_replace("CatalogObject.", "", $arRow['tag']);
if ($arRow['tag'] == 'РекламныеБлоки' && $arRow['type'] == 'open') {
$CUR_LVL = $arRow['level'];
$CUR_ITEM = $rowIterator;
for ($rowIterator++; $values[$rowIterator]['level'] != $CUR_LVL && $values[$rowIterator]['type'] != 'close'; $rowIterator++) {
$arRawItems[$CUR_ITEM][] = $values[$rowIterator];
}
}
else if ($arRow['tag'] != 'РекламныеБлоки' && $arRow['tag'] != 'TableVoz' && $arRow['type'] == 'open' && $arRow['level'] == 3) {
$CUR_LVL = $arRow['level'];
$PROP_REF_CODE = '';
for ($rowIterator++; $values[$rowIterator]['level'] != $CUR_LVL && $values[$rowIterator]['type'] != 'close'; $rowIterator++) {
if ($values[$rowIterator]['tag'] == 'Ref') {
$PROP_REF_CODE = $values[$rowIterator]['value'];
}
if (!empty($PROP_REF_CODE)) {
$arRawProps[$PROP_REF_CODE][$values[$rowIterator]['tag']] = $values[$rowIterator];
}
}
} else if ($arRow['tag'] == 'TableVoz') {
$CUR_LVL = $arRow['level'];
for ($rowIterator++; $values[$rowIterator]['level'] != $CUR_LVL && $values[$rowIterator]['type'] != 'close'; $rowIterator++) {
$CUR_ROW_LVL = $values[$rowIterator]['level'];
$PROP_REF_CODE = '';
$ROW_DATE = '';
$DATE_OK = false;
$CUR_DATE = date('m.Y');
for ($rowIterator++; $values[$rowIterator]['level'] != $CUR_ROW_LVL && $values[$rowIterator]['type'] != 'close'; $rowIterator++) {
if ($values[$rowIterator]['tag'] == 'ID') {
$PROP_REF_CODE = $values[$rowIterator]['value'];
}
if ($values[$rowIterator]['tag'] == 'Month') {
$ROW_DATE = strtotime($values[$rowIterator]['value']);
$ROW_DATE = date('m.Y', $ROW_DATE);
if ($ROW_DATE == $CUR_DATE) {
$DATE_OK = true;
}
}
if ($DATE_OK) {
$arPrices[$PROP_REF_CODE][$values[$rowIterator]['tag']] = $values[$rowIterator];
}
}
}
}
}
// return $arPrices;
// return $arRawItems;
// return $arRawProps;
/*
Необходимые данные:
Название V
Номер блока V
Тип блока
Район V
Адрес V
Сторона V
Описание V
Координаты V
Размер V
Освещение V
Изображения V
Цена за месяц V
*/
// Construct our elements array
foreach ($arRawItems as $key => $arElement) {
$CUR_REF = '';
$tempArr = array();
foreach ($arElement as $arProperty) {
// If property is list item - get list item value
if (strpos($arProperty['attributes']['xsi:type'], 'CatalogRef.') !== false && $arProperty['attributes']['xsi:type'] != 'CatalogRef.РекламныеБлоки' && $arProperty['tag'] != 'ID') {
$arProperty['value'] = $arRawProps[$arProperty['value']]['Description']['value'];
}
$arProperty['value'] = trim($arProperty['value']);
// Construct element array to add / update
switch ($arProperty['tag']) {
case 'DeletionMark':
$tempArr['DELETION'] = $arProperty['value'];
break;
case 'ТипБлока':
$tempArr['PROPERTY_VALUES']['TYPE'] = $arProperty['value'];
$tempArr['NAME'] .= $arProperty['value'].' ';
break;
case 'НомерБлока':
$tempArr['PROPERTY_VALUES']['NUMBER'] = $arProperty['value'];
$tempArr['NAME'] .= $arProperty['value'];
break;
case 'Освещение':
if ($arProperty['value'] == 'true') {
$tempArr['PROPERTY_VALUES']['LIGHT'] = 28; //Yes
} else {
$tempArr['PROPERTY_VALUES']['LIGHT'] = 29; //No
}
break;
case 'Description':
$tempArr['PROPERTY_VALUES']['STREET'] = $arProperty['value'];
break;
case 'Координаты':
$tempArr['PROPERTY_VALUES']['MAP'] = $arProperty['value'];
break;
case 'Размер':
$tempArr['PROPERTY_VALUES']['SIZE'] = $arProperty['value'];
break;
case 'Сторона':
$tempArr['PROPERTY_VALUES']['SIDE'] = $arProperty['value'];
break;
case 'Район':
$tempArr['PROPERTY_VALUES']['AREA'] = $arProperty['value'];
break;
case 'ОсновноеИзображение':
$tempArr['DETAIL_PICTURE'] = CFile::MakeFileArray($work_dir.'/'.$arProperty['value']);
case 'ID':
$tempArr['XML_ID'] = $arProperty['value'];
$CUR_REF = $arProperty['value'];
break;
case 'Описание':
$tempArr['DETAIL_TEXT'] = $arProperty['value'];
break;
case 'Цена':
$tempArr['PRICE'] = $arProperty['value'];
break;
}
}
if ($arPrices[$CUR_REF]['Price']['value']) {
$tempArr['PRICE'] = $arPrices[$CUR_REF]['Price']['value'];
}
if ($arPrices[$CUR_REF]['Status']['value']) {
$tempArr['STATUS'] = $arPrices[$CUR_REF]['Status']['value'];
}
if (!empty($CUR_REF)) {
$arRes['ITEMS'][$CUR_REF] = $tempArr;
}
}
// self::saveTodoFile($arRes['ITEMS']);// Не используется
// return $arRes;
self::log('BEFORE END parseXML: return self::addItems($arRes[\'ITEMS\']');
return self::addItems($arRes['ITEMS']);
}