0

I want to extend sort by drop down for special price or discounted product from toolbar.phtml

<div class="sort-by" style="float:left">
    <fieldset class="sort-by">
      <label><?php echo $this->__('Sort by') ?></label>
        <select onchange="setLocation(this.value)">
          <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>
          <option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> Name - A to Z </option>
          <option value="<?php echo $this->getOrderUrl('name', 'desc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> Name - Z to A </option>
         <option value="<?php echo $this->getOrderUrl('update_at', 'desc') ?>"<?php if($this->isOrderCurrent('update_at') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>Newest First</option>
        </select>
  </fieldset>
</div>

How I can add one more option for discount so products will sort by special price ASC?

1 Answer 1

1

You should only need to insert the sort order, and the collection should already have the special price - add this to your <select>:

<option value="<?php echo $this->getOrderUrl('special_price', 'asc') ?>"<?php if($this->isOrderCurrent('special_price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>Special Price</option>

The only flaw in this method is that it won't filter items from the collection that are not currently on sale, though it will sort them.

1
  • Actually I want to sort product list page so that I will get all discounted product first.
    – Sandesh
    Jul 9, 2013 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.