[-] TR : fix #PSCFV-3403 : check if is an object before loading stock data

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16634 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre committed 2012-08-01 07:45:00 +00:00
1 parent f0c11404bb
commit 218236c1ee
1 file changed
+11 -9
+11 -9
View File
@@ -4808,15 +4808,17 @@ class ProductCore extends ObjectModel
*/ */
public function loadStockData() public function loadStockData()
{ {
// By default, the product quantity correspond to the available quantity to sell in the current shop if (Validate::isLoadedObject($this))
$this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0); {
$this->out_of_stock = StockAvailable::outOfStock($this->id); // By default, the product quantity correspond to the available quantity to sell in the current shop
$this->depends_on_stock = StockAvailable::dependsOnStock($this->id); $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1) $this->out_of_stock = StockAvailable::outOfStock($this->id);
$this->depends_on_stock = StockAvailable::dependsOnStock($this->id);
$this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management` if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1)
FROM '._DB_PREFIX_.'product_shop $this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management`
WHERE id_product='.(int)$this->id.Shop::addSqlRestriction()); FROM '._DB_PREFIX_.'product_shop
WHERE id_product='.(int)$this->id.Shop::addSqlRestriction());
}
} }
/** /**