Remove The Sort By “Position” Options In Magento



In Magento By default there are 3 Sort by Options Position, Name and Price, if you want to remove the Sort by Position options from the dropdown here in this post I am trying to describe how we can remove the Sort by Position options in Magento. I think there are a lot of people that do not ever use this Sort by "Position" options. But it is not a listed attribute into the Magento that you can easily turn on or off as far as sorting goes. So we must have to remove it from the Code and here are the steps given below:

Step 1. Navigate to the /app/design/frontend/default/your_theme/template/catalog/product/list/toolbar.phtml. Look at the bottom of the file, there will be code lines looks like the below:

<?php echo $this->__('Sort by') ?> <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 $_order ?>
    </option>
<?php endforeach; ?>
</select>

Step 2. Just add an if statement like as the below code

<?php echo $this->__('Sort by') ?> <select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
    <?php if ($_order != 'Position') : // Start Removing Sort By "Position" option from the list ?>
        <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
            <?php echo $_order ?>
        </option>
    <?php endif; // End Removing Sort By "Position" option from the list ?>
<?php endforeach; ?>
</select>

It is working fine for me. Hope it helps, Thanks for reading and enjoy the Magento coding.