Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 6169)
+++ /controller/wpsg_ShopController.class.php	(revision 6174)
@@ -1503,7 +1503,7 @@
 					
 			if (!wpsg_isSizedArray($produkt)) throw new \Exception('Produkt (ID:'.$produkt_id.') konnte nicht geladen werden.');
-			
+			 
 			foreach ($override as $k => $v) $produkt[$k] = $v;
-						
+						  
 			// Ãbersetzung einbeziehen
 			if ($this->isOtherLang())
Index: /mods/mod_productgroups/wpsg_productgroup.php
===================================================================
--- /mods/mod_productgroups/wpsg_productgroup.php	(revision 6174)
+++ /mods/mod_productgroups/wpsg_productgroup.php	(revision 6174)
@@ -0,0 +1,159 @@
+<?php
+
+    /**
+     * Model fÃŒr Zugriff auf die Produktgruppen
+     */
+
+    class wpsg_productgroup extends wpsg_model
+    {
+
+	    /**
+		 * LÃ€dt die Daten der Produktgruppe
+		 */
+		public function load($productgroup_id)
+		{
+
+			parent::load($productgroup_id);
+
+			$this->data = $this->db->fetchRow("
+				SELECT 
+					PG.*,
+					(SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count` 
+				FROM
+					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+				WHERE
+					PG.`id` = '".wpsg_q($productgroup_id)."' 
+			");
+
+			if ($this->data['id'] != $productgroup_id || !wpsg_isSizedInt($productgroup_id)) return false;
+
+			return true;
+
+		} // public function __construct($customer_group_id)
+
+	    public function countProducts()
+	    {
+		    
+		    return $this->product_count;
+		    
+	    }
+	    
+        /* Statische Funktionen */
+
+	    public static function getProductgroupSelect()
+	    {
+
+		    return $GLOBALS['wpsg_db']->fetchAssocField("
+		        SELECT
+		            PG.`id`, CONCAT(PG.`name`,' (', (
+		            	SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id` 
+		            ), ')') AS `name` ,
+		            (SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count`
+		        FROM
+		        	`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+		        HAVING
+		            `product_count` > 0
+		        ORDER BY
+		            `name` ASC
+		    ", "id", "name");
+
+	    } // public static function getProductgroupSelect()
+
+        /**
+		 * ZÃ€hlt die Bestellungen anhand des Filters
+		 */
+		public static function count($arFilter)
+		{
+
+			list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
+
+			$strQuery = "
+				SELECT
+					COUNT(*)
+				FROM
+					(
+						SELECT
+						  	DISTINCT PG.`id`
+						FROM
+							`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+							".$strQueryJOIN."
+						WHERE
+							1
+							".$strQueryWHERE." 
+						HAVING
+							1
+							".$strQueryHAVING."											
+					) AS innerSelect
+			";
+
+			return $GLOBALS['wpsg_db']->fetchOne($strQuery);
+
+		} // public static function count($arFilter)
+
+		public static function find($arFilter = array())
+		{
+
+			list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = self::getQueryParts($arFilter);
+
+			$strLimit = "";
+
+			if (wpsg_isSizedArray($arFilter['limit'])) $strLimit = "LIMIT ".wpsg_q($arFilter['limit'][0]).", ".wpsg_q($arFilter['limit'][1]);
+
+			$strQuery = "
+				SELECT
+					PG .`id`
+					".$strQuerySELECT."
+				FROM
+					`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+				WHERE
+					1
+					".$strQueryWHERE."
+				HAVING
+					1
+					".$strQueryHAVING."
+				ORDER BY
+					".$strQueryORDER."		
+				".$strLimit."
+			";
+
+			$arCustomerID = $GLOBALS['wpsg_db']->fetchAssocField($strQuery);
+			$arReturn = array();
+
+			foreach ($arCustomerID as $customer_id)
+			{
+
+				$arReturn[$customer_id] = self::getInstance($customer_id);
+
+			}
+
+			return $arReturn;
+
+		} // public function find($arQuery = array())
+
+		public static function getQueryParts($arFilter = array())
+		{
+
+			$strQuerySELECT = "";
+			$strQueryWHERE = "";
+			$strQueryJOIN = "";
+			$strQueryHAVING = ""; 
+
+			if (wpsg_isSizedString($arFilter['order'], 'name')) { $strQueryORDER = " PG.`name` "; }
+			else if (wpsg_isSizedString($arFilter['order'], 'template_file')) { $strQueryORDER = " PG.`template_file` "; }
+			else if (wpsg_isSizedString($arFilter['order'], 'product_count')) {
+
+				$strQuerySELECT .= ", (SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE P.`pgruppe` = PG.`id`) AS `product_count`) ";
+				$strQueryORDER = " `product_count` ";
+
+			}
+			else $strQueryORDER = " PG.`id` ";
+
+			// Richtung
+			if (wpsg_isSizedString($arFilter['ascdesc'], "DESC")) $strQueryORDER .= " DESC ";
+			else $strQueryORDER .= " ASC ";
+
+			return array($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER);
+
+		} // public function getQueryParts($arFilter = array())
+
+    }
