Friday 12 September 2014

Magento : Custom Sort-By Price say High-To-Low and Low-To-High

Step 1 : Edit toolbar.phtml inside the folder
        app/design/frontend/yourpackage/yourtheme/template/catalog/product/list/toolbar.phtml


Step 2 : You will find the default Magento <select> </select> option over there. If you open this file in notepad++ go to line No.90.

Step 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.

<select onchange="setLocation(this.value)">
            <!-- <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                    <?php echo $this->__($_order) ?>
                </option>
            <?php endforeach; ?> -->
</select>

Step 4 : Then put this code between <select> </select>

<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>


Step 5 : You have Done!

Output :

3 comments:

  1. That's great! But seems to complicated for me(( I always tend to choose reasdy extensions to make sure they work for my Magento version and that they don't require too much coding. For sorting I use this mod https://amasty.com/improved-sorting.html

    ReplyDelete
  2. How can i set, price: High to Low as a default sort option my all pages.

    ReplyDelete
  3. design is working but functionality is not working high to low and low to high

    ReplyDelete