2

Is it possible to make a form that allows the user to input to and from price range rather than calculating specific price ranges?

A lot of eCommerce websites are using this including eBay itself, so I'm curious if they plan to make that in the future, and if not, does the layered navigation accept custom values if I were to implement a form?

1 Answer 1

2

to filter on a specific price range your category url looks something like http://domain.com/categoryurl?price=65-200. To accomplish this I would suggest creating a new template file that has a form with a minimal and maximal price input with a submit button that when clicked will create an url like previously mentioned.

Here is some untested code that might help you along.

In your local.xml add the following to add a new block under the left layered navigation.

<catalog_category_layered>
    <reference name="left">
        <block type="core/template" name="pricefilter" after="-" template="catalog/layer/pricefilter.phtml"/>
    </reference>
</catalog_category_layered>

The pricefilter.phtml would look something like this

<?php echo $this->__('From');?>: <input type="text" name="minvalue" id="pricefilter-minvalue" value=""/><br/>
<?php echo $this->__('To');?>: <input type="text" name="maxvalue" id="pricefilter-maxvalue" value=""/><br/>
<a href="#" id="pricefilter-submit"><?php echo $this->__('Filter');?></a>

<script type="text/javascript">
$('pricefilter-submit').observe('click',function(){
    var minvalue = $('pricefilter-minvalue').value;
    var maxvalue = $('pricefilter-maxvalue').value;

    var dest = window.location.href;
    dest += (window.location.href.indexOf('?') != -1) ? '&' : '?' ;
    dest += 'price=' + minvalue + '-' + maxvalue;

    window.location = dest;
});

2
  • Interesting. I'll have to take a stab at it later today
    – DWils
    Commented Feb 19, 2014 at 16:17
  • I have tried adding ?price=10-150 to the url of my category but it hasn't change anything?
    – Howli
    Commented Oct 13, 2014 at 9:44

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.