Index: /changelog
===================================================================
--- /changelog	(revision 8316)
+++ /changelog	(revision 8317)
@@ -580,9 +580,11 @@
 #4.4.4
 - Feature: Productcodemanagement - Produktcodes (EAN, GTIN, SKU ...) kÃ¶nnen nun in einem neuem Reiter im Produkt eingepflegt werden
+- Feature: Modul Exportprofile: Jede mÃ¶gliche Produktvariantenkombination kann nun als gesondertes Produkt (im CSV-Export) exportiert werden
+- Feature: Modul Exportprofile: Produktdetailname ist nun exportierbar
 - Feature: Modul Produktvarianten: Produktkombinationen fÃŒr Varianten
 - Feature: Modul Produktgruppen: Positionsnummer fÃŒr Produktgruppen im Frontend
 - Feature: Modul Produktgruppen: Markierung wenn Produktgruppe aktiven Rabatt hat in ProduktgruppenÃŒbersicht
-- Feature: Modul Statistik: alte Piwik API durch neue Matomo API ausgetauscht + erweitertes eCommerce tracking mÃ¶glich
-- Feature: Modul Statistik: Google Analytics 4 / Google Tagmanager integriert + Bestelltracking
+- Feature: Modul Statistik: alte Piwik API durch neue Matomo API ausgetauscht + erweitertes Bestelltracking / eCommerce-tracking integriert
+- Feature: Modul Statistik: Google Analytics 4 / Google Tagmanager + Bestelltracking integriert
 - Bugfix: Modul Produktvarianten: EAN bei Varianten auch ohne Produktartikelmodul anzeigbar wenn gefÃŒllt
 - Bugfix: Modul Rechnungen: E-Mails der Sammelrechnungnen werden nun wieder richtig generiert (Anhang + RNr)
Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 8316)
+++ /model/wpsg_product.class.php	(revision 8317)
@@ -81,10 +81,16 @@
 		}
 		
-		public function getCombination(): ?\wpsg\wpsg_combination {
-			
-			if ($this->getProductKey() !== null) {
-				
-				return \wpsg\wpsg_combination::findByProductAndKey($this->getId(), $this->getProductKey());
-				
+		public function getCombination($pvariationID = null): ?\wpsg\wpsg_combination {
+
+			if ($pvariationID !== null) return \wpsg\wpsg_combination::findByProductAndKey($this->getId(), $pvariationID);
+			else
+			{
+
+				if ($this->getProductKey() !== null) {
+					
+					return \wpsg\wpsg_combination::findByProductAndKey($this->getId(), $this->getProductKey());
+					
+				}
+
 			}
 			
@@ -96,7 +102,7 @@
 		 * Gibt den Namen des Produktes zurÃŒck
 		 */
-		public function getProductName($detailname = false) {
-
-			$oCombination = $this->getCombination();
+		public function getProductName($detailname = false, $pvariationID = null) {
+
+			$oCombination = $this->getCombination($pvariationID);
 			
 			if ($oCombination !== null) {
@@ -148,5 +154,5 @@
 		 * @throws Exception
 		 */
-		public function getProductCode(string $code_key = null): ?array {
+		public function getProductCode(string $code_key = null, $pvariationID = null): ?array {
 			
 			$arCodes = ['ean', 'gtin', 'mpn', 'pzn', 'sku', 'upc', 'sin', 'asin', 'gpc', 'isbn', 'issn', 'isin', 'isrc', 'ismn', 'can', 'jan', 'jis', 'apn', 'cpc', 'man', 'ban'];
@@ -156,7 +162,7 @@
 				$code = $this->getMeta($code_key, false, '');
 				
-				if (wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants') && wpsg_ShopController::getShop()->callMod('wpsg_mod_productvariants', 'isVariantsProductKey', [$this->getProductKey()])) {
+				if (wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants')) {
  
-					$oCombination = \wpsg\wpsg_combination::findByProductAndKey($this->getId(), $this->getProductKey());
+					$oCombination = $this->getCombination($pvariationID);
 					
 					if ($oCombination !== null) {
@@ -199,11 +205,11 @@
 		 * @return string
 		 */
-		public function getNr() {
+		public function getNr($pvariationID = null) {
 			
 			$anr = $this->anr;
 		
-			if (wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants') && wpsg_ShopController::getShop()->callMod('wpsg_mod_productvariants', 'isVariantsProductKey', [$this->getProductKey()])) {
- 
-				$oCombination = \wpsg\wpsg_combination::findByProductAndKey($this->getId(), $this->getProductKey());
+			if (wpsg_ShopController::getShop()->hasMod('wpsg_mod_productvariants')) {
+
+				$oCombination = $this->getCombination($pvariationID);
 				
 				if ($oCombination !== null) {
Index: /mods/mod_productvariants/wpsg_combination.class.php
===================================================================
--- /mods/mod_productvariants/wpsg_combination.class.php	(revision 8316)
+++ /mods/mod_productvariants/wpsg_combination.class.php	(revision 8317)
@@ -124,5 +124,5 @@
 			
 			$exist = self::findByProductAndKey($product_id, $var_key);
-			
+
 			if ($exist !== null) return $exist;
 			
Index: /mods/wpsg_mod_export.class.php
===================================================================
--- /mods/wpsg_mod_export.class.php	(revision 8316)
+++ /mods/wpsg_mod_export.class.php	(revision 8317)
@@ -118,4 +118,5 @@
 		   	  	order_online INT(1) NOT NULL COMMENT 'Bestellungen in einer Zeile auffÃŒhren',
 		   	  	order_onetime INT(1) NOT NULL COMMENT 'Bestellungen nur einmal exportieren',
+                csv_pvariants_separated INT(1) NOT NULL COMMENT 'Beim CSV Export jede Variante eines Produktes einzeln in einer extra Zeile auffÃŒhren',
 		   	  	csv_fieldnames INT(1) NOT NULL COMMENT 'Beim CSV Export die Feldnamen in erster Zeile auffÃŒhren',
 		   	  	cron_interval INT(1) NOT NULL DEFAULT '0' COMMENT 'Cron Eisntellunge (Inaktiv/Intervall)',
@@ -530,4 +531,5 @@
                     case 'field_escape': $col = 'field_escape'; $_REQUEST['value'] = wpsg_sinput("text_field", $_REQUEST['value']); break;
                     case 'order_onetime': $col = 'order_onetime'; break;
+                    case 'csv_pvariants_separated': $col = 'csv_pvariants_separated'; break;
                     case 'csv_fieldnames': $col = 'csv_fieldnames'; break;
                     case 'cron_interval': $col = 'cron_interval'; break;
@@ -821,17 +823,59 @@
             }
 
-            foreach ($arData as $oProduct) {
-
-                $row = array();
-
-                foreach ($profil['fields'] as $f) {
-
-                    $row[] = $this->getValue($f, $profil['field_delimiter'], false, $oProduct->id);
-
-                }
-
-                $arExportData[] = $row;
-
-            } // foreach arData
+            if ($this->shop->hasMod('wpsg_mod_productvariants')) 
+            {
+
+                foreach ($arData as $oProduct) 
+                {
+
+                    if (!empty($oProduct->getPossibleProductVariantKeys()) && ($profil['csv_pvariants_separated'] == '1')) 
+                    {
+
+                        //$variants = $this->shop->callMod('wpsg_mod_productvariants', 'getVariants', [$oProduct->id, true, true, true]);
+                        $variants = $oProduct->getPossibleProductVariantKeys();
+
+                        foreach ($variants as $variant) 
+                        {
+
+                            // wpsg_debug($variant);
+
+                            $row = array();
+                            foreach ($profil['fields'] as $f) $row[] = $this->getValue($f, $profil['field_delimiter'], false, $oProduct->id, null, null, $variant['var_key']);
+                            $arExportData[] = $row;
+
+                        }
+
+                    } 
+                    else 
+                    {
+
+                        $row = array();
+                        foreach ($profil['fields'] as $f) $row[] = $this->getValue($f, $profil['field_delimiter'], false, $oProduct->id);
+                        $arExportData[] = $row;
+
+                    }
+
+                }
+
+            } 
+            else
+            {
+
+                foreach ($arData as $oProduct) 
+                {
+
+                    $row = array();
+
+                    foreach ($profil['fields'] as $f) {
+
+                        $row[] = $this->getValue($f, $profil['field_delimiter'], false, $oProduct->id);
+
+                    }
+
+                    $arExportData[] = $row;
+
+                } 
+
+            }
 
             foreach ($arExportData as $row)
@@ -1650,4 +1694,5 @@
                         'produkt_index' => __('Position', 'wpsg'),
                         'produkt_name' => __('Produktname', 'wpsg'),
+                        'produkt_detailname' => __('Produktdetailname', 'wpsg'),
                         'product_url' => __('Produkt-URL', 'wpsg'),
                         'product_picture_url' => __('Produktbild-URL', 'wpsg'),
@@ -1877,6 +1922,6 @@
         }
 
-        public function getValue($f, $profil_separator, $o_id, $p_id = null, $customer_id = null, $order_product_id = null) {
- 
+        public function getValue($f, $profil_separator, $o_id, $p_id = null, $customer_id = null, $order_product_id = null, $pvari_ID = null) {
+
 			$oProduct = null;
 			$oOrderProduct = null;
@@ -2235,5 +2280,6 @@
                 case 'produkt_id': $return = $oProduct->getId(); break;
                 case 'produkt_index': $return = $oOrderProduct->getProductIndex(); break;
-				case 'produkt_name': if (!isset($oProduct)) throw new \Exception(); $return = $oProduct->getProductName(); break;
+				case 'produkt_name': if (!isset($oProduct)) throw new \Exception(); $return = $oProduct->getProductName(false, $pvari_ID); break;
+                case 'produkt_detailname': if (!isset($oProduct)) throw new \Exception(); $return = $oProduct->getProductName(true, $pvari_ID); break;
                 case 'product_url': $return = $oProduct->getProductURL(); break;
                 case 'product_picture_url':
@@ -2358,5 +2404,5 @@
 
                     break;
-                case 'produkt_anr': $return = $oProduct->__get('anr'); break;
+                case 'produkt_anr': $return = $oProduct->getNr($pvari_ID);; break;
                 case 'produkt_menge': $return = $oOrderProduct->__get('menge'); break;
                 case 'produkt_ean': $return = $oProduct->getEAN(); break;
@@ -2404,5 +2450,6 @@
 						if ($field_value === 'product_code_'.$code_key) {
 							
-							if ($oOrderProduct !== null) {
+							if ($oOrderProduct !== null) 
+                            {
 							 
 								$pc_data = $oOrderProduct->getProduct()->getProductCode($code_key);
@@ -2411,12 +2458,15 @@
 								else $return = $pc_data['code'];
 							
-							} else if (isset($oProduct)) {
+							} 
+                            else if (isset($oProduct)) // here
+                            {
 								
-								$pc_data = $oProduct->getProductCode($code_key);
+								$pc_data = $oProduct->getProductCode($code_key, $pvari_ID);
 								
 								if ($pc_data === null) $return = '';
 								else $return = $pc_data['code'];
 								
-							} else throw new \Exception();
+							} 
+                            else throw new \Exception();
 							
 						}
Index: /mods/wpsg_mod_statistics.class.php
===================================================================
--- /mods/wpsg_mod_statistics.class.php	(revision 8316)
+++ /mods/wpsg_mod_statistics.class.php	(revision 8317)
@@ -555,5 +555,5 @@
 					} else $productCat = 'item_category: "false",';
 
-					if ($this->shop->hasMod('wpsg_mod_productvariants')) $arVariInfo = $this->shop->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['product_key']));
+					if ($this->shop->hasMod('wpsg_mod_productvariants')) $arVariInfo = $this->shop->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', [$p['product_key']]);
 					else $arVariInfo = '"false"';
 
Index: /views/mods/mod_export/profil.phtml
===================================================================
--- /views/mods/mod_export/profil.phtml	(revision 8316)
+++ /views/mods/mod_export/profil.phtml	(revision 8317)
@@ -67,4 +67,14 @@
             
             <?php } ?>
+
+            <?php if ($this->view['profil']['export_type'] === wpsg_mod_export::TYPE_PRODUCT) { ?>    
+
+                <div class="wpsg_mod_export_format wpsg_mod_export_format_<?php echo wpsg_mod_export::FORMAT_CSV; ?>" style="display:<?php echo (($this->view['profil']['format'] == wpsg_mod_export::FORMAT_CSV)?'block':'none'); ?>">
+                    
+                    <?php echo wpsg_drawForm_Checkbox('csv_pvariants_separated', __('Produkte variantengetrennt exportieren', 'wpsg'), $this->view['profil']['csv_pvariants_separated'], array('label' => __('Optionen', 'wpsg'), 'inlineEdit' => true, 'inlineEdit_url' => $inlineEdit_url)); ?>
+                    
+                </div>
+
+            <?php } ?>
                 
             <div class="wpsg_mod_export_format wpsg_mod_export_format_<?php echo wpsg_mod_export::FORMAT_CSV; ?>" style="display:<?php echo (($this->view['profil']['format'] == wpsg_mod_export::FORMAT_CSV)?'block':'none'); ?>">
@@ -73,5 +83,5 @@
                 
             </div>
-            
+
         </div>
         
