Adding Custom Search Box to a Magento Home Page

catalogsearchproduct-attribute

I want to add a search box to my home page. All the products in the catalog have an attribute called "compatible devices". User should be able to select their compatible device from a dropdown list and when hit search, the result should display all the products that have the the selected device as their value for "compatible device" attribute. The form should have no other search field. Can someone please suggest a suitable way to achieve this.

Best Answer

Change your "Compatible Devices" attribute to:

Use in Advanced Search: Yes

Then create your own search template. The post action would then post to the catalogsearch/advanced/result page, and the method would be GET

Don't hardcode your dropdown for your available compatible devices, you can get the available options by running:

 $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'YOUR ATTRIBUTE CODE HERE');
 $options = $attribute->getSource()->getAllOptions(false);
Related Topic