// Little refacto
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14170 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+13
-15
@@ -1367,25 +1367,23 @@ class CategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function addShop($id_shop)
|
public function addShop($id_shop)
|
||||||
{
|
{
|
||||||
$sql = '
|
$data = array();
|
||||||
INSERT INTO `'._DB_PREFIX_.'category_shop` (`id_category`, `id_shop`) VALUES
|
|
||||||
';
|
|
||||||
$datas = '';
|
|
||||||
if (!$id_shop)
|
if (!$id_shop)
|
||||||
{
|
{
|
||||||
foreach (Shop::getShops(true) as $shop)
|
foreach (Shop::getShops(false) as $shop)
|
||||||
if (!$this->existsInShop($shop['id_shop']))
|
if (!$this->existsInShop($shop['id_shop']))
|
||||||
$datas .= '('.(int)$this->id.', '.(int)$shop['id_shop'].'),';
|
$data[] = array(
|
||||||
// removing last comma to avoid SQL error
|
'id_category' => (int)$this->id,
|
||||||
$datas = substr($datas, 0, strlen($datas) - 1);
|
'id_shop' => (int)$shop['id_shop'],
|
||||||
} else
|
);
|
||||||
if (!$this->existsInShop($id_shop))
|
}
|
||||||
$datas .= '('.(int)$this->id.', '.(int)$id_shop.')';
|
else if (!$this->existsInShop($id_shop))
|
||||||
|
$data[] = array(
|
||||||
|
'id_category' => (int)$this->id,
|
||||||
|
'id_shop' => (int)$id_shop,
|
||||||
|
);
|
||||||
|
|
||||||
if (empty($datas))
|
return Db::getInstance()->insert('category_shop', $data);
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return Db::getInstance()->execute($sql.$datas);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRootCategories($id_lang = null, $active = true)
|
public static function getRootCategories($id_lang = null, $active = true)
|
||||||
|
|||||||
Reference in New Issue
Block a user