From 6d8d6d2ff538fd587aa3c1d63ee8ad1fc95b372b Mon Sep 17 00:00:00 2001 From: bMancone Date: Wed, 12 Oct 2011 14:38:07 +0000 Subject: [PATCH] // Warehouse : added isEmpty() --- classes/stock/Warehouse.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/stock/Warehouse.php b/classes/stock/Warehouse.php index 51f663d81..9c4d19ab6 100644 --- a/classes/stock/Warehouse.php +++ b/classes/stock/Warehouse.php @@ -102,6 +102,20 @@ class WarehouseCore extends ObjectModel Db::getInstance()->autoExecute('warehouse_shop', $row_to_insert, 'INSERT'); } + /** + * For the current warehouse, returns if the warehouse is empty + * + * @return bool + */ + public function isEmpty() + { + $query = new DbQuery(); + $query->select('SUM(s.physical_quantity)'); + $query->from('stock s'); + $query->where($this->identifier.' = '.(int)$this->id); + return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 0); + } + /** * For a given warehouse, checks if it exists *