// id_category_default fix

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13634 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vChabot
2012-02-27 15:42:48 +00:00
parent 1882cbcf14
commit 78334a05a6
2 changed files with 16 additions and 7 deletions
+11 -6
View File
@@ -4830,14 +4830,19 @@ class ProductCore extends ObjectModel
WHERE `id_product` = '.(int)$id_product);
}
public function updateCategoryDefault($shop = null)
public function updateCategoryDefault($shop = null, $insert = false)
{
if (is_null($shop))
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'product_shop`
SET `id_category_default` = '.(int)$this->id_category_default.'
WHERE `id_shop` = '.(int)$shop->id.'
AND `id_product` = '.(int)$this->id);
if ($insert)
return Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'product_shop`
VALUES ('.(int)$this->id.', '.(int)$shop->id.', '.(int)$this->id_category_default.')');
else
return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'product_shop`
SET `id_category_default` = '.(int)$this->id_category_default.'
WHERE `id_shop` = '.(int)$shop->id.'
AND `id_product` = '.(int)$this->id);
}
}