<?php
/**
 * @author		Kano
 * @copyright	Kano Technology Limited
 * @license		Commercial
 */

defined("_JEXEC") or die("Restricted access");

// Create Cart ID
$session = JFactory::getSession();
if (empty($session->get('cart_id'))) {
	$cart_id = uniqid();
	$session->set('cart_id',$cart_id);
	$app = JFactory::getApplication();
	$app->setUserState( 'com_trade.carts.filter.search','cart_id:'.$cart_id );
}

require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/trade.php';
//require_once JPATH_COMPONENT_SITE.'/helpers/category.php';
require_once JPATH_COMPONENT_SITE.'/helpers/route.php';
if (file_exists(JPATH_LIBRARIES . '/spout/src/Autoloader/autoload.php')) {
	require_once JPATH_LIBRARIES . '/spout/src/Autoloader/autoload.php';
	JLoader::registerNamespace('Box', JPATH_LIBRARIES . '/spout/src', false, false, 'psr4');
}
$controller	= JControllerLegacy::getInstance('Trade');
$input = JFactory::getApplication()->input;

$lang = JFactory::getLanguage();
$lang->load('joomla', JPATH_ADMINISTRATOR);


try {
	$controller->execute($input->get('task'));
} catch (Exception $e) {
	$controller->setRedirect(JURI::base(), $e->getMessage(), 'error');
}

$controller->redirect();
?>
