Hacking form.mini.phtml – list all options of an attribute

  • by

So I needed a slightly customised advanced search for a client.  Really I just needed 1 attribute and prices to be searchable from every page on the site.

<?php
$catalogSearchHelper = $this->helper('catalogsearch');
?>
<?php $maxQueryLength= $this->helper('catalogsearch')->getMaxQueryLength();?>
<form id="search_mini_form" action="<?php echo $this->getUrl('catalogsearch/advanced/result/');?>" method="get">
<input type="hidden" name="order" value="relevance">
<input type="hidden" name="dir" value="desc">
 <div class="header-search">
 
 <!-- This is the original Search field
 <input id="search" type="text" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="input-text" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" />
 -->
 
 <label for="bedrooms">Number of Bedrooms:</label>
 <select name="bedrooms[]" >
<?php
$name='bedrooms';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'bedrooms'); // attribute code here
 foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
 {
 echo '<option value="'.$option['value'].'">'.$option['label'].'</option>';
 } 
?> 
 </select>
 <label for="price[from]">Minimum Price:</label>
 <label for="price[to]">Maximum Price:</label>
 <select name="price[from]" id="minimum">
 <option value="">No Minimum</option> 
 <option value="100000">&pound;100,000</option> 
 <option value="125000">&pound;125,000</option> 
 <option value="150000">&pound;150,000</option> 
 <option value="175000">&pound;175,000</option> 
 <option value="200000">&pound;200,000</option> 
 <option value="225000">&pound;225,000</option> 
 <option value="250000">&pound;250,000</option> 
 </select>
 <select name="price[to]" id="maximum">
 <option value="">No Maximum</option> 
 <option value="100000">&pound;100,000</option> 
 <option value="125000">&pound;125,000</option> 
 <option value="150000">&pound;150,000</option> 
 <option value="175000">&pound;175,000</option> 
 <option value="200000">&pound;200,000</option> 
 <option value="225000">&pound;225,000</option> 
 <option value="250000">&pound;250,000</option> 
 </select>
 
 <button type="submit" title="<?php echo $this->__('Search') ?>" value="Search Properties" class="search-btn">Search Properties</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 Amethyst Homes...') ?>');
 searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
 //]]>
 </script>
 </div>
</form>

Leave a Reply

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.