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

This commit is contained in:
lLefevre committed 2012-08-01 07:45:00 +00:00
1 parent 93de3576ea
commit 465097d075
1 file changed
+3 -1
+3 -1
View File
@@ -4807,17 +4807,19 @@ class ProductCore extends ObjectModel
* Fill the variables used for stock management * Fill the variables used for stock management
*/ */
public function loadStockData() public function loadStockData()
{
if (Validate::isLoadedObject($this))
{ {
// By default, the product quantity correspond to the available quantity to sell in the current shop // By default, the product quantity correspond to the available quantity to sell in the current shop
$this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0); $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
$this->out_of_stock = StockAvailable::outOfStock($this->id); $this->out_of_stock = StockAvailable::outOfStock($this->id);
$this->depends_on_stock = StockAvailable::dependsOnStock($this->id); $this->depends_on_stock = StockAvailable::dependsOnStock($this->id);
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1) if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1)
$this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management` $this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management`
FROM '._DB_PREFIX_.'product_shop FROM '._DB_PREFIX_.'product_shop
WHERE id_product='.(int)$this->id.Shop::addSqlRestriction()); WHERE id_product='.(int)$this->id.Shop::addSqlRestriction());
} }
}
/** /**
* get the default category according to the shop * get the default category according to the shop