Skip to content

Instantly share code, notes, and snippets.

@volandku
Last active February 10, 2020 13:22
Show Gist options
  • Save volandku/87d897d02bf9c7ef0962336d6f047ec1 to your computer and use it in GitHub Desktop.
Save volandku/87d897d02bf9c7ef0962336d6f047ec1 to your computer and use it in GitHub Desktop.
<?php
/**
* @package ${NAMESPACE}
* @subpackage
*
* @copyright A copyright
* @license A "Slug" license name e.g. GPL2
*/
use ws_xml_import\XMLExport;
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
//if (file_exists(dirname(__DIR__) . '/defines.php'))
//{
// require_once dirname(__DIR__) . '/defines.php';
//}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__).'/../../../..');
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once dirname(__DIR__).'/ws_xml_import/xml/xml.php';
class wsImportJoomShopping extends JApplicationCli
{
public $helper = null;
public $plugins = null;
public $starttime = null;
public function doExecute()
{
$links = array();
$p=getopt('u:');
$url=$p['u'];
$app = JFactory::getApplication('administrator'); //Вот только плевать на переданные параметры!!
$this->starttime = time();
$db = JFactory::getDbo();
require_once(JPATH_SITE . '/components/com_jshopping/lib/factory.php');
require_once(JPATH_SITE . '/components/com_jshopping/lib/functions.php');
require_once(JPATH_SITE . '/administrator/components/com_jshopping/models/products.php');
require_once(JPATH_SITE . '/administrator/components/com_jshopping/models/productfields.php');
if (isset($url))
{
$export = new XMLExport;
$export->cli=TRUE;
$ru=$export->langFull[0]; // Не обязательно русский
// Build our language object
$lang = \JLanguage::getInstance($ru);
// Load the language to the API
$app->loadLanguage($lang);
// Register the language object with \JFactory
\JFactory::$language = $app->getLanguage();
// Load the library language files
$app->getLanguage()->load('lib_joomla', JPATH_ADMINISTRATOR);
if ($export->loadURL($url))
{
$export->parseCategories();
$export->getCategories();
$export->writeCategories();
$export->parseAndWriteProducts();
$export->log("message","Теперь памяти используется ".round(memory_get_usage(TRUE)/1000000)." Мб");
}
}
else
{
echo "Не задан параметр -u для адреса xml-файла";
}
}
}
JApplicationCli::getInstance('wsImportJoomShopping')->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment