Skip to content

Instantly share code, notes, and snippets.

@volandku volandku/joomshopping cli
Last active May 27, 2019

Embed
What would you like to do?
<?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
You can’t perform that action at this time.