I want to add a search box to my header where search form will have two drop-down select input fields (for two product attribute). The options in second drop down should depend on the selection made in the first drop down field. for example two fields are laptop brands and screen size, if in the first drop down HP is selected the second drop drown must update(through AJAX)and should contains screen sizes available only for HP and when the user hit search all the individual product should show up. I know how to do this from scratch but i can tweak magento code to achieve this. Can someone please suggest a suitable way?

1 Answer 1


I would build a module to handle this.

If you create a module, and an associated Block, you could plug that block in wherever required to ensure it appears where you like it; it can then have an associated layout and template for you to customise.

As this Block is a fully qualified class, it will be able to handle multiple methods with regard to preparing the dataset.

Depending on your actual dataset though, and how complex it is, it may be better to pass the template a multidimensional array, such as the below:

 - HP Category 1
 - HP Category 2
 - Samsung Category 1
 - Samsung Category 2

This way, you can use JavaScript without AJAX, to build your drop downs, and it will be a little more responsive overall (you wont have to wait for a separate request).

If you do want to use AJAX however, you'll need a controller set up with a action to return the associated data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.