// 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
This commit is contained in:
rMalie
2011-10-11 13:32:18 +00:00
parent 329a0966ca
commit c340b46f7d
+12 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -93,6 +93,17 @@ class ShopUrlCore extends ObjectModel
$res &= Db::getInstance()->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;
}