From 465097d075d96f1ceb2b60a76defb2d02d174ca5 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Wed, 1 Aug 2012 07:45:00 +0000 Subject: [PATCH] [-] TR : fix #PSCFV-3403 : check if is an object before loading stock data --- classes/Product.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index 1811a863c..95729d79c 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -4808,15 +4808,17 @@ class ProductCore extends ObjectModel */ public function loadStockData() { - // By default, the product quantity correspond to the available quantity to sell in the current shop - $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0); - $this->out_of_stock = StockAvailable::outOfStock($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) - - $this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management` - FROM '._DB_PREFIX_.'product_shop - WHERE id_product='.(int)$this->id.Shop::addSqlRestriction()); + if (Validate::isLoadedObject($this)) + { + // By default, the product quantity correspond to the available quantity to sell in the current shop + $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0); + $this->out_of_stock = StockAvailable::outOfStock($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) + $this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management` + FROM '._DB_PREFIX_.'product_shop + WHERE id_product='.(int)$this->id.Shop::addSqlRestriction()); + } } /**