2

I want to add more options in the 'sort by' box. How can I add these and what are other options to add there?

enter image description here

In this image there are 2 options, Name and Price. How can I add more options?

1

To sort by other attributes, you have to do make the attribute sortable:

go to Catalog > Attributes > Manage Attributes, select the attribute that you want to add to the "Sort by" menu and set "Used for Sorting in Product Listing" to "Yes":

screenshot

If this does not work, your theme might have changed the default dropdown. In this case, search for "setAvailableOrders" in the theme layout files and add the following lines below that action:

<action method="addOrderToAvailableOrders" translate="label">
    <code>YOUR_ATTRIBUTE_CODE</code>
    <label>YOUR_ATTRIBUTE_LABEL</label>
</action>
| improve this answer | |
  • It worked through admin options so didnt try 2nd method. thanks – Jai Oct 6 '15 at 4:16
-1

use this Before that make sure you work on theme don't edit core file Sort by High price to low price

/app/design/frontend/package/your-theme/template/catalog/product/list/toolbar.phtml file

Find below code

<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) ?>
</option>

Replace into

<?php if ($_order != 'Price'): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) ?>
</option>
<?php else: ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key) && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) . ': Low to High' ?>
</option> 
<option value="<?php echo $this->getOrderUrl($_key, 'desc') ?>"<?php if($this->isOrderCurrent($_key) && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
    <?php echo $this->__($_order) . ': High to Low' ?>
</option> 
<?php endif; ?>

Sort By Latest Product

app/code/core/Mage/Catalog/Block/Product/List/toolbar.php

Find Below code

if ($this->getCurrentOrder()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        return $this;

Replace into

if ($this->getCurrentOrder()) {
          if(($this->getCurrentOrder())=='recentlyadded'){
              $this->_collection->setOrder('entity_id','desc');
          }
          else {
           $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
          }
        }
        return $this;

Also replace same this function also in same file Find

public function setDefaultOrder($field)
{
    if (isset($this->_availableOrder[$field])) {
        $this->_orderField = $field;
    }
    return $this;
}

Replace into

public function setDefaultOrder($field) {
    if (isset($this->_availableOrder[$field])) {
        $this->_availableOrder = array(

            'recentlyadded'    => $this->__('Newest Product'),
            'name'        => $this->__('Name'),
            'price'       => $this->__('Price'),
        );
        $this->_orderField = $field;
    }

    return $this;
}
| improve this answer | |
  • I havnt tried your method bur will give it try. Thanks for your answer. – Jai Oct 6 '15 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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