How to add Custom Sorting Option in Magento :
Often there is a need to make a custom Sorting Options in Magento. Though Magento provides a great support for adding sorting options of our choice but at times we need to do it ourself.
Suppose you want to sort product by Price say High-To-Low and Low-To-High. This is not supported by Magento but you can easily do it using some custom coding.
Following are the steps that requires to be taken
2)You will find the default Magento <select> </select> option over there.
3)You can either comment out that section and create a new one or just add your option in there to make it working too.
4) Now suppose you want to add an option for sorting by price from High-to-low and Low-To-High you can write the code for it as follows
<option value=”<?php echo $this->getOrderUrl(‘price’, ‘asc’) ?>”<?php if($this->isOrderCurrent(‘price’) && $this->getCurrentDirection() == ‘asc’): ?> selected=”selected”<?php endif; ?>>Price : Low To High</option>
<option value=”<?php echo $this->getOrderUrl(‘price’, ‘desc’) ?>”<?php if($this->isOrderCurrent(‘price’) && $this->getCurrentDirection() == ‘desc’): ?> selected=”selected”<?php endif; ?>>Price : High To Low</option>
Now, what we are doing here is we are getting the attribute price and sorting it in ascending in descending order. Sorting it in ascending order will sort the product with Low-High Price whereas sorting in descending will sort it from High-Low price.
Similarly you can do such custom sorting for many options. Please provide your feedback and suggestion on this in comment section