From a03464ada9b064c52ba2242586cfd78f8883d709 Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 24 Jan 2012 09:12:19 +0000 Subject: [PATCH] // Fix multishop when an URL is not found in shop_url git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12632 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/shop/Shop.php | 47 ++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index fce97b500..6e5bae4af 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -274,37 +274,30 @@ class ShopCore extends ObjectModel } } - if ($id_shop) + if (!$id_shop && defined('_PS_ADMIN_DIR_')) { - // Get instance of found shop - $shop = new Shop($id_shop); - if (!Validate::isLoadedObject($shop) || !$shop->active) - { - // 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 ! - if (!Validate::isLoadedObject($default_shop)) - throw new PrestaShopException('Shop not found'); - - $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().ltrim($_SERVER['SCRIPT_NAME'], '/').'?'.$_SERVER['QUERY_STRING']; - header('location: '.$url); - exit; - } + // If in admin, we can access to the shop without right URL + $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); + $shop->physical_uri = str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/'; + $shop->virtual_uri = ''; + return $shop; } - else - if (defined('INSTALL_VERSION')) - $shop = new Shop(); - else if (defined('_PS_ADMIN_DIR_')) - { - // If in admin, we can access to the shop without right URL - $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); - $shop->physical_uri = str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))); - $shop->virtual_uri = ''; - } - 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 + $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); + + // Hmm there is something really bad in your Prestashop ! + if (!Validate::isLoadedObject($default_shop)) throw new PrestaShopException('Shop not found'); + $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php'.'?'.$_SERVER['QUERY_STRING']; + header('location: '.$url); + exit; + } + return $shop; }