// id_category_default fix

This commit is contained in:
vChabot
2012-02-27 15:42:48 +00:00
parent 43ab853ffa
commit 2090f2d279
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);
}
}