// Some performance improvement #PSCFV-2658
This commit is contained in:
+17
-20
@@ -274,14 +274,6 @@ class ShopCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function initialize()
|
public static function initialize()
|
||||||
{
|
{
|
||||||
// Get list of excluded uri
|
|
||||||
$dirname = dirname(__FILE__);
|
|
||||||
$directories = scandir($dirname.'/../');
|
|
||||||
$excluded_uris = array();
|
|
||||||
foreach ($directories as $directory)
|
|
||||||
if (is_dir($dirname.'/../'.$directory) && (!preg_match ('/^\./', $directory)))
|
|
||||||
$excluded_uris[] = $directory;
|
|
||||||
|
|
||||||
// Find current shop from URL
|
// Find current shop from URL
|
||||||
if (!($id_shop = Tools::getValue('id_shop')) || defined('_PS_ADMIN_DIR_'))
|
if (!($id_shop = Tools::getValue('id_shop')) || defined('_PS_ADMIN_DIR_'))
|
||||||
{
|
{
|
||||||
@@ -339,24 +331,29 @@ class ShopCore extends ObjectModel
|
|||||||
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||||
$shop->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/');
|
$shop->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/');
|
||||||
$shop->virtual_uri = '';
|
$shop->virtual_uri = '';
|
||||||
return $shop;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
$shop = new Shop($id_shop);
|
|
||||||
if (!Validate::isLoadedObject($shop) || !$shop->active || !$id_shop)
|
|
||||||
{
|
{
|
||||||
// No shop found ... too bad, let's redirect to default shop
|
$shop = new Shop($id_shop);
|
||||||
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
if (!Validate::isLoadedObject($shop) || !$shop->active || !$id_shop)
|
||||||
|
{
|
||||||
|
// No shop found ... too bad, let's redirect to default shop
|
||||||
|
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||||
|
|
||||||
// Hmm there is something really bad in your Prestashop !
|
// Hmm there is something really bad in your Prestashop !
|
||||||
if (!Validate::isLoadedObject($default_shop))
|
if (!Validate::isLoadedObject($default_shop))
|
||||||
throw new PrestaShopException('Shop not found');
|
throw new PrestaShopException('Shop not found');
|
||||||
|
|
||||||
$url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING'];
|
$url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING'];
|
||||||
header('location: '.$url);
|
header('location: '.$url);
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$context_id_shop = $shop->id;
|
||||||
|
self::$context_id_shop_group = $shop->id_shop_group;
|
||||||
|
self::$context = self::CONTEXT_SHOP;
|
||||||
|
|
||||||
return $shop;
|
return $shop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
|||||||
|
|
||||||
/* Initialize the current Shop */
|
/* Initialize the current Shop */
|
||||||
Context::getContext()->shop = Shop::initialize();
|
Context::getContext()->shop = Shop::initialize();
|
||||||
Shop::setContext(Shop::CONTEXT_SHOP, Context::getContext()->shop->id);
|
|
||||||
define('_THEME_NAME_', Context::getContext()->shop->getTheme());
|
define('_THEME_NAME_', Context::getContext()->shop->getTheme());
|
||||||
define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
|
define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user