// Warehouse : added isEmpty()

This commit is contained in:
bMancone
2011-10-12 14:38:07 +00:00
parent 81d914c74b
commit 6d8d6d2ff5
+14
View File
@@ -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
*