<Предложение> <Ид>ab43f47d-b47a-11e6-9504-406186caa5f1<Ид/> <Артикул/> <Наименование>Кондитерское изделие фигурное Дед Мороз 60г<Наименование/> <БазоваяЕдиница Код="796" НаименованиеПолное="Штука" МеждународноеСокращение="PCE"> <Пересчет> <Единица>796<Единица/> <Коэффициент>1<Коэффициент/> <Пересчет/> <БазоваяЕдиница/> <Цены> <Цена> <Представление> 57 RUB за шт<Представление/> <ИдТипаЦены>70f63c69-5c82-11e6-8eb6-406186caa5f1<ИдТипаЦены/> <ЦенаЗаЕдиницу>57<ЦенаЗаЕдиницу/> <Валюта>RUB<Валюта/> <Коэффициент>1<Коэффициент/> <Цена/> <Цены/> <strong><Количество>27<Количество/></strong> <Склад ИдСклада="456684b4-0cd2-4157-a228-4ed059397969" КоличествоНаСкладе="27"/> <Предложение/>
$prices = current((array)$raw_data['Цены']); //['Цена'] $data = array( "price" => !empty($prices['ЦенаЗаЕдиницу']) ? $prices['ЦенаЗаЕдиницу'] : 0, );
$prices = current((array)$raw_data['Цены']); //['Цена'] $amount = current($raw_data['Количество']); $data = array( "price" => !empty($prices['ЦенаЗаЕдиницу']) ? $prices['ЦенаЗаЕдиницу'] : 0, "amount" => !empty($raw_data['Количество']) ? $raw_data['Количество'] : 0 );
$prices = current((array)$raw_data['Цены']); $amount = current($raw_data['Количество']); $data = array( "price"=>!empty($prices['ЦенаЗаЕдиницу']) ? $prices['ЦенаЗаЕдиницу'] : 0, "amount" => !empty($amount) ? $amount : 0 );
print_r($data); exit;
<?php print '<pre>'; ini_set('display_errors', 1); $modx->switchContext('web'); $modx->setLogLevel(3); $modx->setLogTarget('HTML'); $namespace = 'modimporter'; // Неймспейс комопонента // Добавить веб-сессию текущего пользователя // Если вы не авторизованы во фронте, можете получить // в результате выполнения сообщение Доступ запрещён! // $modx->user->addSessionContext('web'); // Удалить веб-сессию текущего пользователя // $modx->user->removeSessionContext('web'); // Сбросить сессию компонента // $_SESSION["SM_1C_IMPORT"] = array(); // Вывести данные сессии компонента // print_r($_SESSION["SM_1C_IMPORT"]); // print_r($_SESSION["SM_1C_IMPORT"]); // unset($_SESSION["modImporter"]); $params = array( // "step" => "SDFsdf", // "debug" => false, // "mode" => "checkauth", // "modimporter_step" => "modimporter_checkauth", // "modimporter_step" => "modimporter_console_init", // "modimporter_step" => "modimporter_drop_tmp_tables", // "modimporter_step" => "modimporter_create_tmp_tables", // "modimporter_step" => "modimporter_write_tmp_xlsx_shared_strings", // "modimporter_step" => "modimporter_write_tmp_categories", "modimporter_step" => "modimporter_write_tmp_data", // "modimporter_step" => "modimporter_import_data", // "modimporter_step" => "modimporter_import_update_categories", // "modimporter_step" => "modimporter_import_update_categories", // "modimporter_step" => "modimporter_import_create_categories", // "modimporter_step" => "modimporter_import_update_goods", // "modimporter_step" => "modimporter_import_create_goods", // "modimporter_step" => "modimporter_import_flush_prices", // "modimporter_step" => "modimporter_import_create_prices", // "filename" => "import.xml", // "username" => "admin", // "password" => "wefwef", "outputCharset" => "utf-8", ); // $_SERVER['PHP_AUTH_USER'] = 'admin'; // $_SERVER['PHP_AUTH_PW'] = 'admin'; if(!$response = $modx->runProcessor('modimporter/import/console', $params , array( 'processors_path' => $modx->getObject('modNamespace', $namespace)->getCorePath().'processors/', ))){ print "Не удалось выполнить процессор"; return; } $memory = round(memory_get_usage(true)/1024/1024, 4).' Mb'; print "<div>Memory: {$memory}</div>"; $totalTime= (microtime(true) - $modx->startTime); $queryTime= $modx->queryTime; $queryTime= sprintf("%2.4f s", $queryTime); $queries= isset ($modx->executedQueries) ? $modx->executedQueries : 0; $totalTime= sprintf("%2.4f s", $totalTime); $phpTime= $totalTime - $queryTime; $phpTime= sprintf("%2.4f s", $phpTime); print "<div>TotalTime: {$totalTime}</div>"; print_r($response->getResponse()); // $objects = $response->getObject(); // foreach($objects as $object){ // }
$q2 = $this->modx->newQuery('modResource'); $q2->command('update'); $q2->set($data); $q2->where(array( "id" => $tmp_object->resource_id, ));
UPDATE `modx_site_content` SET `price` = 19 WHERE `modx_site_content`.`id` = 37216
UPDATE `modx_site_content` WHERE `modx_site_content`.`id` = 21043