Advanced Search sidebar box

Featured Image

I was playing a bit with that advanced search form in Magento, so i thought it would be nice touch to add it to left or right column of the store.

Since that multiple selects were causing problems and i also had to get rid of breadcrumb, i created block which extends Mage_CatalogSearch_Block_Advanced_Form functionality, added a little javascript  and packed it all to small example module:

advanced-search-sidebar.rar

Unpack the rar, copy files at its appropriate place following directory structure, disable/enable cache to rebuild configs, layouts, blocks, and you’re on.

advanced-search-sidebar-box-2

I left few comments in the code, thought someone may find them useful. Also be sure to modify

template/sidebarsearch/advanced/sidebar.phtml

and

layout/sidebarsearch.xml

to suit your shop needs, since css is hardcoded in template for example. Regards.

48
Top

Care to rate this post?

Author

Ivan Weiler

Technical Educator and Consultant

Ivan is a Technical Educator and Consultant. He gained lots of experience managing some of the most complex Magento projects we had at Inchoo.

Other posts from this author

Discussion 48 Comments

Add Comment
  1. ro_beck

    I don’t use yet …
    But i think this module is a great idea.

    tks u for this!

  2. Great job! Thanks

  3. Hi Great Tutorial and awesome blog. Is there a way just have selected search attributes?

    Cheers,
    Bruce

  4. There is “Use in advanced search” option for each attribute, if that’s what you mean. Navigate to Catalog->Attributes->Manage Attributes, click to edit attribute and you’ll see it.

  5. Thanks, but I need it the option in the side block to be different form the advanced search page. Any way of doing this?

    Cheers,
    Bruce

  6. No, not without additional programming ..

    The easiest way would be to configure Magento to use in search all attributes you need and then modify both templates to not display what you don’t need there.

  7. roberto

    well…..this post is grate… there is just a little problem… if in your search you conffigurated with date it dosent work. i tryed to fix it but nothing…..any answear?

  8. nikl

    Looks great, I would love to have this advanced search column only appear on the advanced search results page, while the advanced search link itself still takes me to the normal advanced search window. Ill try and work this out right now

  9. Paaaaa

    Is there any way to arrange the position of the attributes, like in layered navigation? I want the price to be at the end..

    Any hint? Thank You.

  10. Paaaaa

    Found solution at official forum: Change the file \app\core\mage\catalogsearch\model\advanced.php at around line 47 to setOrder by “position” rather than by “attribute_id”. Then in the attribute settings use the position field as the order you want your fields to appear in.
    Then it uses the position value of attribute.

    Thanks any way for extension)

  11. Ups

    Small bug when search by price and write in first input any price, to second input leave a blank box, I get an error:
    Undefined index: to in app/code/core/Mage/CatalogSearch/Model/Advanced.php on line 176

  12. Is possible to unload the advanced sidebar just in the home page?.

    Thanks

  13. Sergio

    Same error:
    Undefined index: to in app/code/core/Mage/CatalogSearch/Model/Advanced.php on line 176
    In price range when for example fill only one field.
    ¿?

  14. @ Ups and Sergio, a simple sollution for this bug is to add the following line:

    if (is_array($value) && !isset($value['to'])) $value['to'] = ”;

    in app/code/coreMage/CatelogSearch/Model/Advanced.php

    before the line:

    if (is_array($value) && (isset($value['from']) || isset($value['to']))){

  15. heidi

    Am I missing something? I’m using Magento 1.4. I followed the directions and nothing appears in the sidebar. Do I need to edit another file or something? Love this post if I could get it to work, thanks much.

  16. Ups

    Mike Houtepen better solution copy paste form template in this block and all…. :)

  17. Great tip with sorting the advanced search attributes, worked a treat in 1.3.2.4, thanks!

  18. @ Ups;

    That was my first solutions and did not solve all of it, the solution i gave a few comments earlier was not that good either anyway…

    Solved it an other way now :).. Anyways thanks ;)

  19. Tihku

    @ Mike Houtepen ;

    Hey, I’ve been having the same problem, if I leave forms empty, it just throws and error. I’d need advanced search on the left with category, but both this system here^^ and category-thing on the wiki just throws only errors to me. (http://www.magentocommerce.com/wiki/how-to/how_to_add_search_by_category_to_advanced_search) Could someone please upload a working sidebar on the left with category option? I’d be really thankful!

  20. sunyen

    how do i add the advanced search sidebar into all my product pages (catalog), not just the homepage?

    thanks!!!

  21. William

    Hi,

    Great piece of code thanks.

    My products have some Custom Options set (size), is it possible we could include these in the advanced search?

    These Custom Options do not show up in the attributes field and am not sure if there is another way to assign these to the advanced search.

  22. Erik

    I still get the following error when one price is entered in the price range fields:
    Undefined index: to in app/code/core/Mage/CatalogSearch/Model/Advanced.php on line 176

    Is there a solution to get this working?

    Thanks!!

  23. Allison

    This was a lifesaver, thank you!!

  24. Hi,

    great post!

    I’m in the process of learning magento, and I’m just wondering is something like this possible like on this page: http://goo.gl/IYdA6. Filters in the middle of the page sort some other things like brands, price selection .. more detailed search I think.

  25. NCG

    HI, I am new to Magento.. I would like to know if this can be installed / configured to work with Magento 1.5.0.1 version? where can i download the latest version and any how to steps to configure it? PLEASE ANY HELP.

  26. Wally

    I have installed the sidebar and I would like to be able to search using Date. I have created a custom attribute that is visible in advance search and each product has a date associated to it. The sidebar however is not showing the calendar pop-up so a date can be entered. Is there a way to fix this so searching by date is possible? Thanks so much.

  27. Hello, I am running Magento 1.5, I am new to Magento and have only been working for a month now with it. I feel that I’m missing a step here because after importing the code it’s not working.

  28. I want only ajax based advance search module

  29. Ben

    I can confirm this works in 1.6 … just make sure you uncomment the ‘default’ block in the sidebarsearch.xml file – this brought me unstuck initally.

  30. good works! but i like to have it show left filter in the search results page. any ideas? thank you :D

  31. I love you.

  32. COBAY

    Good Idea !
    Thanks.

  33. Dmitry

    Thanks a lot. I use the latest magento version and your module still works :-)

  34. Hi, can anyone please help me get this advanced search module to show up in my header? I want to replace the simple search with this advanced search.

    Ver 1.5.1

    Thanks

  35. With regards to changing the sort order of the attributes in the advanced search, just changing:

    ->setOrder(‘main_table.attribute_id’, ‘asc’

    to

    ->setOrder(‘main_table.position’, ‘asc’)

    will not work because “main_table.position” doesn’t actually exist (in version 1.6.2). All you need to do is simply change:

    ->setOrder(‘main_table.attribute_id’ )

    TO

    ->setOrder(‘additional_table.position’, ‘asc’)

    This can be found in app\code\core\Mage\CatalogSearch\Model\Advanced.php on line 118

  36. Makoto

    I can´t translate the word “Show All” of dropdown menu of the search box. I modified these files app/code/local/Inchoo/SidebarSearch/Block/Advanced/Sidebar.php

    app/design/frontend/default/default/template/sidebarsearch/advanced/sidebar.phtml

    But no success. Any know how?

  37. dragy

    I have same problem with “Show All” translate. Anybody know? thx

  38. Makoto

    dragy
    my “Show All” word suddenly changed after months. I believe its some cache issue. It just takes long time for the translation to be reflected.

  39. Akash Patel

    Is it possible to add layered navigation in advanced search result like magento default navigation display in search result page.

  40. Purvi123

    thanks

  41. Avi

    hiya guys, this is an awesome side bar, i would like to create have it on other pages as well as the home page is this possible,
    also is there a way i have have 2 side bars both with different fields for different searches.

  42. Varun Jain

    Hi,
    This advance search is a geat feature of magento.
    Usually in e-com CMS, the search is basically a filteration of products. But my requriement is to have this type advance search as the normal search.
    Can I add more attributes accoding to my requriement which are not there in the attribute of catalog. I want a Custom Search, with fixed values to look for, with drop downs as the search criteria. These dropdowns will be filled by the data, which is already present in the DB.
    As I’m newbie to Magento, can you please help me in this. Thanks.

  43. Anna

    It still working after so may year but not with all attribute can be use like Date from – Date to. The date calendar will not pop up as it does in advance page for search there. Maybe it’s time do some upgrade here????

  44. Hello Anna,
    Thank you for the revamp request. We will inform the author next week and I believe you can expect the rewrite during this month.

  45. Anna

    Hi, It’s me Anna again. I’m using it on my website and it’s working fine. But i want to add this search to other pages like category listings and other pages. How can i add it to them?

  46. Hi, This advance search is a geat feature of magento.

    it’s work fine in Magento 1.7.0.1

    but I can’t see the module in Magento 1.9 with the default thema “rwd”

    you can help me, please?

    Tnx for your wonderfull job & blog

    Raffaele

  47. I solved the problem now works in Magento 1.9 thema “rwd”

    I copied these folders:
    app\design\frontend\default\default\layout
    app\design\frontend\default\default\template

    and additions to the template active in

    app/design/frontend/rwd/default

    You may verify the correctness?

    Tnx Raffaele

  48. Heeso

    Thank you so much for this box.

    I’ve been trying to remove some irrelevant search fields but I had no luck, and I even tried to change the order at least and I also couldn’t.

    Anyone knows how?

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top