Index: /changelog
===================================================================
--- /changelog	(revision 7900)
+++ /changelog	(revision 7902)
@@ -458,4 +458,5 @@
 - Bugfix: Backend Kundenvariablen zeigt Auswahl direkt nach Wechsel des Variablentypes an
 - Bugfix: Weitere Kundendaten werden in Admin- und Kundenmail und Bestellverwaltung angezeigt
+- Bugfix: Sortierung nach Preis Ab- und Austeigend korrigiert (Produktansichten / Theme)
 - Change: Mit Rechnunskorrektur Statuswechsel optional mÃ¶glich
 - Change: Im Produkt im Backend werden jetzt alle Produktvariablen angezeigt nicht nur die beim bestellen gesetzen
Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 7900)
+++ /model/wpsg_product.class.php	(revision 7902)
@@ -772,5 +772,5 @@
 				".$strLimit."
 			";
-              
+
 			$arID = $GLOBALS['wpsg_db']->fetchAssocField($strQuery);
 			$arReturn = array();
@@ -782,9 +782,7 @@
 			//if (wpsg_isSizedInt($arFilter['hideNotBuyable'])) $force_load = true;
 
-			foreach ($arID as $id)
-			{
-
-				if ($load === true || $force_load === true)
-				{
+			foreach ($arID as $id) {
+
+				if ($load === true || $force_load === true) {
 
 					$arReturn[$id] = self::getInstance($id);
@@ -798,6 +796,5 @@
 					if (isset($arReturn[$id]) && $force_load === true && $load === false) $arReturn[$id] = $id;
 
-				}
-				else $arReturn[$id] = $id;
+				} else $arReturn[$id] = $id;
 
 			}
@@ -805,11 +802,14 @@
             if (isset($arFilter['order']) && $arFilter['order'] === 'price') {
 
-                uasort($arReturn, function($a, $b) {
+                uasort($arReturn, function($a, $b) use ($arFilter) {
 
                     if (!is_object($a)) $a = wpsg_product::getInstance($a);
                     if (!is_object($b)) $b = wpsg_product::getInstance($b);
 
-                    if ($a->getMinPrice() == $b->getMinPrice()) return 0;
-                    return ($a->getMinPrice() < $b->getMinPrice())?-1:1;
+	                if ($arFilter['ascdesc'] === 'DESC') $order = 1;
+	                else $order = -1;
+
+                    if ($a->getMinPrice() === $b->getMinPrice()) return 0;
+                    return ($a->getMinPrice() < $b->getMinPrice())?$order:-1 * $order;
 
                 } );
@@ -821,6 +821,5 @@
 		} // public function find($arQuery = array())
 
-		public static function getQueryParts($arFilter = array())
-		{
+		public static function getQueryParts($arFilter = array()) {
 
 			$strQuerySELECT = "";
@@ -841,6 +840,5 @@
 			if (wpsg_isSizedString($arFilter['price_max'])) $strQueryWHERE .= " AND P.`preis` <= '".wpsg_q($arFilter['price_max'])."' ";
 
-            if (wpsg_isSizedString($arFilter['s']))
-            {
+            if (wpsg_isSizedString($arFilter['s'])) {
 
                 if (preg_match('/ID:(\d+)?/i', $arFilter['s'], $m)) {
@@ -944,12 +942,10 @@
 			else if (wpsg_isSizedString($arFilter['order'], 'anr')) { $strQueryORDER = " P.`anr` "; }
             else if (wpsg_isSizedString($arFilter['order'], 'pos')) { $strQueryORDER = " PP.`menu_order` "; $bJoinPost = true; }
-			else if (wpsg_isSizedString($arFilter['order'], 'pgruppe'))
-			{
+			else if (wpsg_isSizedString($arFilter['order'], 'pgruppe')) {
 
 				$strQuerySELECT .= " , (SELECT PG.`name` FROM `".WPSG_TBL_PRODUCTS_GROUP."` AS PG WHERE PG.`id` = P.`pgruppe`) AS `order_count` ";
 				$strQueryORDER = " order_count ";
 
-			}
-			else $strQueryORDER = " P.`id` ";
+			} else $strQueryORDER = " P.`id` ";
 
             if ($bJoinPost) {
@@ -959,6 +955,5 @@
             }
             
-            if ($bJoinVariants)
-            {
+            if ($bJoinVariants) {
 
                 $strQueryJOIN .= " 
Index: /mods/wpsg_mod_productindex.class.php
===================================================================
--- /mods/wpsg_mod_productindex.class.php	(revision 7900)
+++ /mods/wpsg_mod_productindex.class.php	(revision 7902)
@@ -522,8 +522,8 @@
 
 			if ($handle) {
-				while ($file = readdir($handle))
-				{
-					if (is_file(WPSG_PATH_VIEW.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file))
-					{
+
+				while ($file = readdir($handle)) {
+
+					if (is_file(WPSG_PATH_VIEW.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file)) {
 
 						$arTemplates[] = $file;
@@ -533,39 +533,43 @@
 				}
 
-			}
-
-			@closedir($handle);
+				@closedir($handle);
+
+			}
 
 			$handle = @opendir(WPSG_PATH_USERVIEW_OLD.'/mods/mod_productindex/layouts/');
 
 			if ($handle) {
-				while ($file = readdir($handle))
-				{
-					if (is_file(WPSG_PATH_USERVIEW_OLD.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file) && !in_array($file, $arTemplates))
-					{
+
+				while ($file = readdir($handle)) {
+
+					if (is_file(WPSG_PATH_USERVIEW_OLD.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file) && !in_array($file, $arTemplates)) {
 
 						$arTemplates[] = $file;
 
 					}
-				}
-			}
-
-			@closedir($handle);
+
+				}
+
+				@closedir($handle);
+
+			}
 
 			$handle = @opendir(WPSG_PATH_USERVIEW.'/mods/mod_productindex/layouts/');
 
 			if ($handle) {
-				while ($file = readdir($handle))
-				{
-					if (is_file(WPSG_PATH_USERVIEW.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file) && !in_array($file, $arTemplates))
-					{
+
+				while ($file = readdir($handle)) {
+
+					if (is_file(WPSG_PATH_USERVIEW.'/mods/mod_productindex/layouts/'.$file) && preg_match('/(.*).phtml$/', $file) && !in_array($file, $arTemplates)) {
 
 						$arTemplates[] = $file;
 
 					}
-				}
-			}
-
-			@closedir($handle);
+
+				}
+
+				@closedir($handle);
+
+			}
 
 			return $arTemplates;
@@ -574,4 +578,2 @@
 
 	} // class wpsg_mod_productindex extends wpsg_mod_basic
-
-?>
Index: /views/mods/mod_productindex/page_metabox.phtml
===================================================================
--- /views/mods/mod_productindex/page_metabox.phtml	(revision 7900)
+++ /views/mods/mod_productindex/page_metabox.phtml	(revision 7902)
@@ -8,10 +8,10 @@
 
 <style type="text/css">
- 
-#wpsg_mod_productindex_layer { height:20rem; }
-#wpsg_mod_productindex_layer select,
-#wpsg_mod_productindex_layer input { width:25rem; }
-#wpsg_mod_productindex_layer #wpsg_mod_productindex_hideOrder,
-#wpsg_mod_productindex_layer #wpsg_mod_productindex_hideViewSelect { width:15px; height:15px; }
+
+    #wpsg_mod_productindex_layer { height:20rem; }
+    #wpsg_mod_productindex_layer select,
+    #wpsg_mod_productindex_layer input { width:25rem; }
+    #wpsg_mod_productindex_layer #wpsg_mod_productindex_hideOrder,
+    #wpsg_mod_productindex_layer #wpsg_mod_productindex_hideViewSelect { width:15px; height:15px; }
 
 </style>
@@ -91,25 +91,24 @@
 </div> 
 
-<script type="text/javascript">/* <![CDATA[ */
+<script>
 
 	/**
 	 * Zeigt / Versteckt die Optionen fÃŒr die ProduktÃŒbersichtsseite
 	 */
-	function wpsg_mod_productindex_activate()
-	{
-		
-		if (jQuery('#wpsg_mod_productindex_active').attr('checked'))
-		{
+	function wpsg_mod_productindex_activate() {
+
+		if (jQuery('#wpsg_mod_productindex_active').prop('checked')) {
+
 			jQuery('#wpsg_mod_productindex_layer').show();
-		}
-		else
-		{
+
+		} else {
+
 			jQuery('#wpsg_mod_productindex_layer').hide();
+
 		}
 		
-	} // wpsg_mod_productindex_activate()
+	}
 	
-	function wpsg_mod_productindex_switchShow()
-	{
+	function wpsg_mod_productindex_switchShow() {
 
 		var show = jQuery('#wpsg_mod_productindex_show').val();
@@ -118,5 +117,5 @@
 		jQuery('.wpsg_mod_productindex_layer_' + show).show();
 		
-	} // function wpsg_mod_productindex_switchShow()
+	}
 	
 	jQuery(document).ready(function() {
@@ -130,3 +129,3 @@
 	} );
 	
-/* ]]> */</script>
+</script>
