Index: /lib/wpsg_imagehandler.class.php
===================================================================
--- /lib/wpsg_imagehandler.class.php	(revision 6691)
+++ /lib/wpsg_imagehandler.class.php	(revision 6692)
@@ -78,4 +78,6 @@
 			
 			add_post_meta($attachment_id, 'wpsg_produkt_id', $product_id);
+			
+			return $attachment_id;
 			
 		} // public function addImageToProduct($file, $product_id)
Index: /mods/wpsg_mod_productvariants.class.php
===================================================================
--- /mods/wpsg_mod_productvariants.class.php	(revision 6691)
+++ /mods/wpsg_mod_productvariants.class.php	(revision 6692)
@@ -166,4 +166,84 @@
 		} // public function product_addedit_content(&$product_content, &$produkt_data)
 
+		public function produkt_copy(&$produkt_id, &$copy_id)
+		{
+			
+			// Kopieren der Varianten/Variationen
+			$variants = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_VARIANTS."` WHERE `product_id` = '".wpsg_q($produkt_id)."'");
+			$pos = 0;
+			
+			foreach ($variants as $v) {
+				
+				$v['product_id'] = $copy_id;
+				$v['pos'] = $pos;
+				$vid = $v['id'];
+				unset($v['id']);
+				$newvid = $this->db->ImportQuery(WPSG_TBL_VARIANTS, $v);
+				
+				// WPSG_TBL_PRODUCTS_VARIANT schreiben
+				$pv = array();
+				$pv['variant_id'] = $newvid;
+				$pv['product_id'] = $copy_id;
+				$pv['pos'] = $pos;
+				unset($pv['id']);
+				$newpvid = $this->db->ImportQuery(WPSG_TBL_PRODUCTS_VARIANT, $pv);
+				$pos++;
+				
+				$varis = $this->db->fetchAssoc("SELECT * FROM `".WPSG_TBL_VARIANTS_VARI."` WHERE `variant_id` = '".wpsg_q($vid)."'");
+
+				$mimages = array();
+				
+				foreach ($varis as $vv) {
+					$vv['variant_id'] = $newvid;
+					$vvid = $vv['id'];
+					unset($vv['id']);
+					$newvvid = $this->db->ImportQuery(WPSG_TBL_VARIANTS_VARI, $vv);
+
+					$pvari = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS_VARIATION."` WHERE `variation_id` = '".wpsg_q($vvid)."' AND `product_id` = '".wpsg_q($produkt_id)."'");
+					$pvari['variation_id'] = $newvvid;
+					$pvari['product_id'] = $copy_id;
+					
+					// images/images_set
+					$images = explode(',', $pvari['images']);
+					$images_set = explode(',', $pvari['images_set']);
+					$ih = new wpsg_imagehandler();
+					
+					$nimages = array();
+					$nimages_set = array();
+					
+					foreach ($images as $postid) {
+
+						if (!in_array($postid, $mimages['alt'])) {
+							$mimages['alt'][] = $postid;
+							$post = $this->db->fetchRow("SELECT * FROM `".$GLOBALS['wpdb']->prefix."posts` WHERE `ID`='".wpsg_q($postid)."'");  
+							// addImageToProduct($file, $product_id)
+							$npostid = $ih->addImageToProduct($post['guid'], $copy_id);
+							//$nimages[] = $npostid;
+							$mimages['neu'][] = $npostid;
+							
+						}
+
+					}
+
+					foreach ($images_set as $iset) {
+						$ak = array_search($iset, $mimages['alt']);
+						$nimages_set[] = $mimages['neu'][$ak];
+					}
+					foreach ($images as $iset) {
+						$ak = array_search($iset, $mimages['alt']);
+						$nimages[] = $mimages['neu'][$ak];
+					}
+					
+					$pvari['images'] = implode(',', $nimages);
+					$pvari[images_set] = implode(',', $nimages_set);
+					unset($pvari['id']);
+					$newpvid = $this->db->ImportQuery(WPSG_TBL_PRODUCTS_VARIATION, $pvari);
+					
+				}
+				
+			}
+			
+		}	// public function produkt_copy($produkt_id, $copy_id)
+		
 		public function template_redirect()
 		{
