Index: /changelog
===================================================================
--- /changelog	(revision 8485)
+++ /changelog	(revision 8486)
@@ -651,2 +651,5 @@
 - Feature: GiroCode in Bestellabschluss, Kundenemail, Rechnung
 - Feature: Begrenzung auf einen Gutschein je Bestellung mÃ¶glich
+
+#4.4.12
+- Feature: Exportprofile/Statistik - Export von KÃ€ufen
Index: /lib/filter_functions.inc.php
===================================================================
--- /lib/filter_functions.inc.php	(revision 8485)
+++ /lib/filter_functions.inc.php	(revision 8486)
@@ -722,5 +722,5 @@
         global $wp_filesystem;
     
-        if (!isset($_REQUEST['plugin']) && $_REQUEST['plugin'] != WPSG_FOLDERNAME.'/wpshopgermany.php') return;
+        if (!isset($_REQUEST['plugin']) || $_REQUEST['plugin'] != WPSG_FOLDERNAME.'/wpshopgermany.php') return;
     
         if (!isset($_REQUEST['_ajax_nonce'])) echo __('Kopiere Shop aus dem Pluginverzeichnis ...', 'wpsg').'<br />';
Index: /mods/wpsg_mod_statistics.class.php
===================================================================
--- /mods/wpsg_mod_statistics.class.php	(revision 8485)
+++ /mods/wpsg_mod_statistics.class.php	(revision 8486)
@@ -1393,4 +1393,53 @@
 		} //public function product_addedit_content(&$product_content, &$product_data)
 		
+		/**
+		 * Wird vom Exportmodul aufgerufen wenn die verfÃŒgbaren Felder geladen werden
+		 */
+		public function wpsg_mod_export_loadFields(&$arFields) {
+		
+			$arFields[20]['fields']['wpsg_mod_productstatistic_sold_lastyear'] = wpsg_translate(__('VerkÃ€ufe #1#', 'wpsg'), date('Y', strtotime('-1 year')));
+			$arFields[20]['fields']['wpsg_mod_productstatistic_sold_currentyear'] = wpsg_translate(__('VerkÃ€ufe #1#', 'wpsg'), date('Y'));
+			$arFields[20]['fields']['wpsg_mod_productstatistic_sold'] = __('VerkÃ€ufe insgesamt', 'wpsg');
+			
+		}
+		
+		/**
+		 * Gibt einen Wert fÃŒr eine Exportspalte zurÃŒck. Das Modul schreibt das Ergebnis in $return zurÃŒck
+		 */
+		public function wpsg_mod_export_getValue(&$return, $field_value, $o_id, $p_id, $order_product_id, $profil_separator) {
+		
+			if (!in_array($field_value, ['wpsg_mod_productstatistic_sold_lastyear', 'wpsg_mod_productstatistic_sold_currentyear', 'wpsg_mod_productstatistic_sold'])) return;
+			
+			if (intval($p_id??0) > 0) {
+				
+				$strQueryWHERE = "";
+				
+				if ($field_value !== 'wpsg_mod_productstatistic_sold') {
+					
+					$strQueryWHERE .= " AND YEAR(O.`cdate`) = ".match($field_value) {
+						'wpsg_mod_productstatistic_sold_lastyear' => intval(date('Y', strtotime('-1 year'))),
+						'wpsg_mod_productstatistic_sold_currentyear' => intval(date('Y')),
+						default => throw new \Exception()
+					};
+					
+				}
+				
+				$return = intval($this->db->fetchOne("
+					SELECT
+						SUM(OP.`menge`)
+					FROM
+						`".WPSG_TBL_ORDERPRODUCT."` AS OP
+						LEFT JOIN `".WPSG_TBL_ORDER."` AS O ON(O.`id` = OP.`o_id`)
+					WHERE
+						O.`type_payment` != '' AND
+						O.`type_payment` IS NOT NULL AND
+						O.`status` IN(".$this->observeStatuscodes.") AND
+						OP.`p_id` = '".intval($p_id)."'
+						".$strQueryWHERE."
+				"));
+			
+			}
+		
+		}
 		
 	}
