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 *