
<?php
class ModelExtensionDashboardStockStatusSummary extends Model {
    public function getProductsGroupedByStockStatus() {
        $query = $this->db->query("SELECT ss.name AS stock_status, COUNT(*) AS total 
            FROM " . DB_PREFIX . "product p 
            LEFT JOIN " . DB_PREFIX . "stock_status ss ON p.stock_status_id = ss.stock_status_id 
            WHERE ss.language_id = '" . (int)$this->config->get('config_language_id') . "' 
            GROUP BY p.stock_status_id 
            ORDER BY ss.name");

        return $query->rows;
    }
}
