Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Custom search- category listing in select box
Jr. Member
Total Posts:  13
Joined:  2008-10-22

Hi all,

I have to make a custom search for my site with option to search with Keyword, Manufacturer and category. The manufacturer and category are select boxes and I have to populate them with dynamic content. How can I select all the categories and manufacturers?

please help me on how to do this..

Thanks in advance..

Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  767
Joined:  2007-12-29

There are two approaches: either make your own search form (and keep the advanced search) or modify the advanced search form (to effectively lose the default form).

There are some instructions on the former approach here:

Alternatively, if you are prepared to forego the advanced form, read on…

Change to directory app/design/frontend/default/[theme]/template/catalogsearch/advanced and quickly backup the files so that you can refer to them when it all goes wrong…

Now open up form.phtml and change the title text to something more suitable, e.g.:

<div class="page-title">
<h2><?php echo $this->__('Search for products by name, brand and sport') ?></h2>

Now change what search results are retrieved with the inchoo technique given above, insert an ‘if’ statement below the line <?php $_code = $_attribute->getAttributeCode() ?>

For instance:
<?php if($_code == 'manufacturer'||$_code == 'name'||$_code == 'sport'||$_code == 'brochurecode'): ?>

You will need to check what attributes you have setup in Admin->Catalogue->Manage Attributes and use the attribute code rather than the label.

to close off the ‘if’, find the closing /li tag and add a line after it with <?php endif; ?>

Open app/locale/en_GB/Mage_CatalogSearch.csv and change the ‘Advanced Catalogue Search’ text to something more friendly, e.g. “Find products by brand or sport”. There should now be different text in the breadcrumbs to the page title.

You should now have a cut down form that just has attributes you want for your mini search, plus the original full search file backed up. Test it before moving on, you will note that categories still need to be added. (Try the full inchoo method when you get time and let me know if you have any luck with it!)

You will need to go through your attributes and make sure they are to show up in advanced search, you could turn off all except the ones you want and not bother with the above code, that depends on how many attributes you have and whether you want to try the inchoo method of creating a supplemental search form.

Fortunately someone else has done categories, so reopen the form.phtml and add the following after the <?php endforeach; ?>

<label for="category_search_field">Search by Category:</label>
<select name="category" id="category_search_field">
<option value="">-- Any Category --</option>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php if($_category->hasChildren()): ?>
<option class="parent-cat" value="<?= $_category->getId(); ?>"><?php echo $_category->getName();?></option>
<?  foreach ($_category->getChildren() as $subcategory):
if($subcategory->getIsActive()) : ?>
<option value="<?php echo $subcategory->getId(); ?>"<?= ($this->getRequest()->getQuery('category') == $subcategory->getId() ? ' selected="selected"': "") ?>><?php echo $subcategory->getName(); ?></option>
<?php endif; endforeach; ?>
<? elseif($_category->getIsActive()): ?>
<option value="<?= $_category->getId(); ?>"><?php echo $_category->getName();?></option>
<? endif; ?>
<?php endforeach ?>

Now move over to the wiki howto for the rest of the instructions:

You should now have a cut-down search page. Thank Emily.

Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  639
Joined:  2009-08-22

Check out these extension. They greatly improve the quality and relevance of search results Advanced Search for Shared Hosting

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top