JPK JPK - 1 year ago 86
PHP Question

Magento custom search form

I am trying to create custom search functionality in Magento 1.9. Instead of writing it from scratch, I want to piggy back the default search functionality and add in custom filters. First I copied the form.min template and replaced with drop downs that I want to use.


$catalogSearchHelper = $this->helper('catalogsearch');

$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();

<form id="search_custom_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">

<div class="select-box item">
<label for="finder">GIFT FINDER</label>
<select id="customS" name="finder">
<option value="">Please select</option>
foreach ($_categories as $key => $value) {
echo("<option value='" . $value["name"] . "'>" . $value["name"] . "</option>");

<div class="item">
<label for="for">FOR</label>
<select id="for">
<option value="">Please select</option>
<option value="him">HIM</option>
<option value="her">HER</option>

<div classs="item">
<label for="delivery">DELIVERY OPTION</label>
<select id="delivery">
<option value="express">EXPRESS DELIVERY</option>
<option value="standard">STANDARD POST</option>

<div classs="item">
<label for="price">DELIVERY OPTION</label>
<select id="price">
<option value="<250">LESS THAN £250</option>
<option value=">250">MORE THAN £250</option>

<button type="submit" title="<?php echo $this->__('Find') ?>" class="button search-button"><span><span><?php echo $this->__('Find') ?></span></span></button>

<script type="text/javascript">
var searchForm = new Varien.searchForm('search_custom_form', '', '');

I have included the above template on my home page using
{{block type="core/template" name="custom-search" as="custom-search" template="catalogsearch/form.custom.phtml"}}
, I have copied the core files into my own template folder and now I find myself stuck.
Can anyone offer a better alternative or solution as to what I should do?


Answer Source

Found a much easier option here. I copied the catalogsearch folder to my theme, copied the advanced search form and placed it on my home page. Now I can customise the form and the query as I see fit.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download