Magento – Search form to search only products within specific attribute set

attribute-setquerysearch

We have two product types in our Magento catalog/store, "default" and "Machine." Wondering if there's a way to set up a search page for each to only perform search in a specific attribute set. Default search code below. Can I modify this? If so, how? If not, any recommendations to best achieve?

<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
    <div class="form-search">
        <input id="search" type="text" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" placeholder="Search" class="input-text" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>"/>
        <button type="submit" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span></button>
        <div id="search_autocomplete" class="search-autocomplete"></div>
        <script type="text/javascript">
        //<![CDATA[
            var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('Search') ?>');
            searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
        //]]>
        </script>
    </div>
</form>

Best Answer

You need add filter to catalogsearch results template magento_dir/app/design/frontend/../.../catalogsearch/result.phtml

Code:

Mage::getSingleton('catalogsearch/layer')->getProductCollection()->addFieldToFilter('addAttributeToFilter', <ATTRIBUTE_SET_ID>);
Related Topic