Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 6315)
+++ /model/wpsg_product.class.php	(revision 6316)
@@ -600,5 +600,5 @@
 				".$strLimit."
 			";
-
+ 
 			$arID = $GLOBALS['wpsg_db']->fetchAssocField($strQuery);
 			$arReturn = array();
Index: /mods/wpsg_mod_productview.class.php
===================================================================
--- /mods/wpsg_mod_productview.class.php	(revision 6315)
+++ /mods/wpsg_mod_productview.class.php	(revision 6316)
@@ -266,7 +266,7 @@
 				
 			}
-			
+	 
 			$arProductviewArray = $this->getSelectedProductArray($atts);
-			  
+			   
 			$this->shop->view['wpsg_mod_productview'] = wpsg_array_merge($this->shop->view['wpsg_mod_productview'], $arProductviewArray);
 			$this->shop->view['wpsg_mod_productview']['index'] = wpsg_getInt($GLOBALS['wpsg_mod_productview_index'], 1);
@@ -317,9 +317,9 @@
 			if (wpsg_isSizedString($atts['product_ids']))
 			{
-			 
+			
 				$arFilter = array(
 					'product_ids' => wpsg_trim(array_unique(explode(',', $atts['product_ids'])))
 				);
-				
+			
 			}
 			else if (wpsg_isSizedString($atts['productgroup_ids']))
Index: /mods/wpsg_mod_produktartikel.class.php
===================================================================
--- /mods/wpsg_mod_produktartikel.class.php	(revision 6315)
+++ /mods/wpsg_mod_produktartikel.class.php	(revision 6316)
@@ -96,6 +96,6 @@
 		public function be_ajax() 
 		{ 
-			 
-			if (wpsg_getStr($_REQUEST['do'], 'setWPMLPathKey'))
+			
+			if (wpsg_isSizedString($_REQUEST['do'], 'setWPMLPathKey'))
 			{
 				
@@ -107,4 +107,104 @@
 				$this->shop->addBackendMessage(__('Der Custom Post Type fÃŒr die Produkte kann nun ÃŒbersetzt werden.', 'wpsg'));				
 				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=ueber&subaction=systemcheck');
+				
+			}
+			else if (wpsg_isSizedString($_REQUEST['do'], 'index_rebuild'))
+			{
+				
+				$arProductIDs = $this->db->fetchAssocField("SELECT `id` FROM `".WPSG_TBL_PRODUCTS."` ", "id");
+				
+				if (wpsg_isSizedArray($arProductIDs))
+				{
+				
+					// Ich lÃ¶sche alle Posts zu denen es die Produkte nicht mehr gibt
+					$this->db->Query("
+						DELETE FROM 
+							`".$this->shop->prefix."posts` 
+						WHERE  
+							`wpsg_produkt_id` NOT IN (".wpsg_q(implode(',', $arProductIDs)).") AND
+							`wpsg_produkt_id` > 0
+					");
+					
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', array(
+						'max' => sizeof($arProductIDs),
+						'product_ids' => $arProductIDs
+					));
+					 					
+					$this->shop->addBackendMessage(__('Zuordnungen werden neu aufgebaut. Bitte schlieÃen Sie die Seite nicht bis der Vorgang abgeschlossen ist.', 'wpsg'));				
+									
+				}
+				else
+				{
+									
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
+					
+					$this->shop->addBackendMessage(__('Ein Aufbau der Zuordnung nicht nicht notwendig.', 'wpsg'));
+					
+				}
+				
+				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel');
+				
+			}
+			else if (wpsg_isSizedString($_REQUEST['do'], 'rebuild'))
+			{
+				
+				$arToDo = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');				
+				$arProductIDs = $arToDo['product_ids'];
+				
+				$i = 0;
+				$limit = 20; 
+				 
+				foreach ($arProductIDs as $k => $product_id)
+				{
+					
+					$product_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."' ");
+					$post_data = $this->db->fetchRow("SELECT * FROM `".$this->shop->prefix."posts` WHERE `wpsg_produkt_id` = '".wpsg_q($product_id)."' ");
+					
+					$_REQUEST['wpsg_mod_produktartikel']['path'] = wpsg_getStr($post_data['post_name'], '');
+					$_REQUEST['wpsg_mod_produktartikel']['kommentare'] = wpsg_getStr($post_data['comment_status'], '');
+					$_REQUEST['wpsg_produktartikel_menuorder'] = wpsg_getStr($post_data['menu_order'], '');
+					
+					if (wpsg_isSizedInt($product_data['lang_parent']))
+					{
+						
+						$_REQUEST['wpsg_lang'] = $product_data['lang_code'];
+						
+						$this->produkt_save_translation($product_data['lang_parent'], $product_data['id']);
+						
+					}
+					else
+					{
+					
+						$this->produkt_save($product_data['id']);
+						
+					}
+					
+					unset($arProductIDs[$k]);
+					
+					$i ++;
+					
+					if ($i >= $limit) break;
+					
+				}
+				
+				if (wpsg_isSizedArray($arProductIDs))
+				{
+					
+					$arToDo['product_ids'] = $arProductIDs;
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', $arToDo);
+					$done = 1 - (sizeof($arProductIDs) / $arToDo['max']); 
+						
+				}
+				else
+				{
+					
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
+					$done = 1;
+					
+				}
+				
+				wpsg_header::JSONData(array(
+					'done' => $done
+				));
 				
 			}
@@ -189,4 +289,7 @@
 		public function settings_edit()
 		{
+			
+			// Rebuild
+			$this->shop->view['ToRebuild'] = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');
 			
 			// VerfÃŒgbare Produkttemplates
@@ -304,4 +407,5 @@
 			
 			$post_content = $this->shop->renderProdukt($copy_id);
+			$post_content = $this->clear_post_content($post_content);
 			
 			$post_data = $this->db->fetchRow("
@@ -914,4 +1018,6 @@
 				}
 				
+				$post_content = $this->clear_post_content($post_content);
+				
 				$data = array(
 					"post_title" => wpsg_q($post_title), 
@@ -1001,4 +1107,11 @@
 		} // private function getPostIdFromProductId($product_id)
 		
+		private function clear_post_content($post_content) 
+		{
+			
+			$post_content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $post_content);
+			
+		} // private function clear_post_content($post_content)
+		
 		/**
 		 * FÃŒgt die Abfrage fÃŒr den PostType an den Wordpress Query
Index: /views/mods/mod_produktartikel/settings_edit.phtml
===================================================================
--- /views/mods/mod_produktartikel/settings_edit.phtml	(revision 6315)
+++ /views/mods/mod_produktartikel/settings_edit.phtml	(revision 6316)
@@ -39,4 +39,81 @@
 <?php } ?>
  
+<br />
+
+<?php echo wpsg_drawForm_TextStart(); ?>	
+		
+		<?php $proz_done = 1; if (wpsg_isSizedArray($this->view['ToRebuild']['product_ids'])) { 
+			
+			$proz_done = 1 - (sizeof($this->view['ToRebuild']['product_ids']) / $this->view['ToRebuild']['max']);
+						 
+		?> 
+		
+		<span id="wpsg_mod_produktartikel_rebuild">
+			<p><?php echo __('Wird derzeit aufgebaut, bitte warten ...', 'wpsg'); ?></p>
+				
+			<div class="progress">
+				<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="<?php echo $proz_done * 100; ?>" aria-valuemax="100" style="width:<?php echo $proz_done * 100; ?>%">
+					<span><span class="value"><?php echo round($proz_done * 100); ?></span>% <?php echo __('Komplett', 'wpsg'); ?></span>
+				</div>
+			</div>
+		</span>
+		
+		<?php } ?>
+	<p>
+		<a href="<?php echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel&noheader=1&do=index_rebuild'; ?>"><?php echo __('Neu aufbauen', 'wpsg'); ?></a>
+	</p>
+
+	<?php echo wpsg_drawForm_TextEnd(__('Zuordnung Produkt zu Artikel', 'wpsg'), array('noP' => true)); ?>
+
+	<?php if ($proz_done < 1) { ?>
+	<script type="text/javascript">/* <![CDATA[ */
+	
+		var proz_done = <?php echo $proz_done; ?>;
+		
+		function wpsg_mod_produktartikel_rebuild()
+		{
+		 	
+			if (proz_done >= 1) return;
+			
+			jQuery.ajax( {
+				url: '<?php echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel&noheader=1&do=rebuild'; ?>',
+				error: function(data) {
+					
+					jQuery('#wpsg_mod_produktartikel_rebuild').html('<p><?php echo __('Neuaufbau abgeschlossen.', 'wpsg'); ?></p>');
+					
+				},
+				success: function(data) {
+					
+					if (typeof data.done == "undefined") return;
+										
+					proz_done = parseFloat(data.done);
+					console.log(proz_done);
+					if (proz_done >= 1)
+					{
+						
+						jQuery('#wpsg_mod_produktartikel_rebuild').html('<p><?php echo __('Neuaufbau abgeschlossen.', 'wpsg'); ?></p>');
+						
+					}
+					else 
+					{
+						
+						jQuery('#wpsg_mod_produktartikel_rebuild').find('.progress-bar').attr("aria-valuemin", proz_done * 100).css('width', (proz_done * 100) + '%').find('span.value').html(Math.round(proz_done * 100));
+						
+						wpsg_mod_produktartikel_rebuild();
+						
+					}
+					
+				}
+			} );
+			
+		}
+		
+		wpsg_mod_produktartikel_rebuild();
+	
+	/* ]]> */</script>
+	<?php } ?>
+
+<br />
+
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_produktartikel_facebook', __('Facebook Integration', 'wpsg'), $this->get_option('wpsg_mod_produktartikel_facebook'), array('help' => 'wpsg_mod_produktartikel_facebook')); ?>
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_produktartikel_google', __('Google+ Integration', 'wpsg'), $this->get_option('wpsg_mod_produktartikel_google'), array('help' => 'wpsg_mod_produktartikel_google')); ?>
