// when upgrade process (INSTALL_VERSION defined), initialize return now an empty shop object (+ die2Exception)

This commit is contained in:
mMarinetti
2011-12-15 17:42:24 +00:00
parent e0471f3406
commit e85b4e9319
+21 -10
View File
@@ -213,6 +213,7 @@ class ShopCore extends ObjectModel
/** /**
* Find the shop from current domain / uri and get an instance of this shop * Find the shop from current domain / uri and get an instance of this shop
* if INSTALL_VERSION is defined, will return an empty shop object
* *
* @return Shop * @return Shop
*/ */
@@ -263,19 +264,29 @@ class ShopCore extends ObjectModel
} }
} }
// Get instance of found shop if($id_shop)
$shop = new Shop($id_shop);
if (!Validate::isLoadedObject($shop) || !$shop->active)
{ {
// No shop found ... too bad, let's redirect to default shop // Get instance of found shop
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); $shop = new Shop($id_shop);
if (!$default_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 ! // Hmm there is something really bad in your Prestashop !
die('Shop not found'); if (!Validate::isLoadedObject($default_shop))
$url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().ltrim($_SERVER['SCRIPT_NAME'], '/').'?'.$_SERVER['QUERY_STRING']; throw new PrestashopException('Shop not found');
header('location: '.$url);
exit; $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().ltrim($_SERVER['SCRIPT_NAME'], '/').'?'.$_SERVER['QUERY_STRING'];
header('location: '.$url);
exit;
}
} }
else
if (defined('INSTALL_VERSION'))
$shop = new Shop();
else
throw new PrestashopException('Shop not found');
return $shop; return $shop;
} }