From c340b46f7d40210a3f0ecc6faf7c7302aa85734b Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 11 Oct 2011 13:32:18 +0000 Subject: [PATCH] // Fix main flag for shop_url when a shop_url is updated git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9233 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/shop/ShopUrl.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/shop/ShopUrl.php b/classes/shop/ShopUrl.php index ea3b4b780..5c765506e 100644 --- a/classes/shop/ShopUrl.php +++ b/classes/shop/ShopUrl.php @@ -1,6 +1,6 @@ autoExecute(_DB_PREFIX_.'shop_url', array('main' => 1), 'UPDATE', 'id_shop_url = '.(int)$this->id); $this->main = true; + // Reset main URL for all shops to prevent problems + $sql = 'SELECT s1.id_shop_url FROM '._DB_PREFIX_.'shop_url s1 + WHERE ( + SELECT COUNT(*) FROM '._DB_PREFIX_.'shop_url s2 + WHERE s2.main = 1 + AND s2.id_shop = s1.id_shop + ) = 0 + GROUP BY s1.id_shop'; + foreach (Db::getInstance()->executeS($sql) as $row) + Db::getInstance()->autoExecute(_DB_PREFIX_.'shop_url', array('main' => 1), 'UPDATE', 'id_shop_url = '.$row['id_shop_url']); + return $res; }