Magento: Search by Category

http://www.panticz.de/sites/default/files/magento/catalogsearch/form.mini.phtml

helper('catalogsearch')->getResultUrl() ?>" method="get">
    
helper('catalogsearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogsearch')->getEscapedQueryText() ?>" class="input-text" /> <?php $startCategory = 2227; ?> ">Alle Kategorien <?php $searchCategory = Mage::app()->getRequest()->getParam('cat'); $cats = Mage::getModel('catalog/category')->load($startCategory)->getChildren(); $catIds = explode(',', $cats); $categories = array(); foreach($catIds as $catId) { $category = Mage::getModel('catalog/category')->load($catId); $categories[$category->getName()] = $catId; } ksort($categories, SORT_STRING); ?> <?php foreach($categories as $name => $catId): ?> " <?php if($catId == $searchCategory) echo "selected"?>><?php echo $name; ?> <?php endforeach; ?> __('Search') ?>" class="button"><?php echo $this->__('Search') ?>
//__('') ?>'); searchForm.initAutocomplete('<?php echo $this->helper('catalogsearch')->getSuggestUrl() ?>', 'search_autocomplete'); //]]>
<?php /* old version $categories = Mage::getModel('catalog/category')->load(2227)->getChildren(); $catIds = explode(',',$categories); foreach($catIds as $catId) { $category = Mage::getModel('catalog/category')->load($catId); $categoryName = $category->getName(); echo "$categoryName\n"; } */ ?> 1

http://www.panticz.de/sites/default/files/magento/catalogsearch/catalogsearch.xml.diff

--- ./app/design/frontend/base/default/layout/catalogsearch.xml	2010-11-29 15:05:49.000000000 +0100
+++ ./app/design/frontend/default/default/layout/catalogsearch.xml	2010-11-29 15:29:58.000000000 +0100
@@ -51,7 +51,7 @@
         
         
         
-            page/3columns.phtml
+            page/2columns-left.phtml
         
         
             
@@ -69,6 +69,7 @@
                     two_columns_right4
                     three_columns3
                     product_list_toolbar
+                    4
                 
                 
                 
@@ -85,7 +86,7 @@
         Advanced Search Form
         
         
-            page/2columns-right.phtml
+            page/2columns-left.phtml
         
         
             js_csscalendar/calendar-win2k-1.css
@@ -107,16 +108,21 @@
         
         
         
-            page/2columns-right.phtml
+            page/2columns-left.phtml
         
         
             
                 
+                    
+                        
+                    
                     empty6
                     one_column5
                     two_columns_left4
                     two_columns_right4
                     three_columns3
+                    product_list_toolbar
+                    4
                 
                 
                 
@@ -131,7 +137,7 @@
         
 
         
-            page/1column.phtml
+            page/2columns-left.phtml
         
         
             
1

http://www.panticz.de/sites/default/files/magento/catalogsearch/Query.php.diff

--- ./app/code/core/Mage/CatalogSearch/Model/Mysql4/Query.php.org	2010-12-15 16:32:26.000000000 +0100
+++ ./app/code/core/Mage/CatalogSearch/Model/Mysql4/Query.php	2010-12-15 16:34:40.000000000 +0100
@@ -64,6 +64,9 @@
      */
     public function loadByQuery(Mage_Core_Model_Abstract $object, $value)
     {
+        $startCategory = 2227;
+        $searchCategory = Mage::app()->getRequest()->getParam('cat');
+        if($searchCategory == $startCategory) {
         $select = $this->_getReadAdapter()->select()
             ->from($this->getMainTable())
             ->where('synonym_for=?', $value)
@@ -74,6 +77,7 @@
             $object->setData($data);
             $this->_afterLoad($object);
         }
+        }
 
         return $this;
     }
1

Links:
http://stackoverflow.com/questions/4273898/how-to-sort-a-category-list-array-alphabetically-in-magento