Magento: How To Remove The “Position” Sort Option

Magento Icon

I had a client ask me today to remove the “Position” option from the toolbar on the category product listing. I realized that there are probably a lot of people that don’t ever utilize position, and therefore it is basically useless and should be removed so it doesn’t cause any confusion for the people browsing the store.

Unfortunately, this is not a listed attribute that you can easily turn on or off as far as sorting goes. So, we have to do it the harder way and dive into the code.

There may be a “better” way to do this, I’m not sure, but this is super easy and it works. All you have to do is edit the file /app/design/frontend/yourpackage/yourtheme/template/catalog/product/list/toolbar.phtml. Towards the bottom, you’ll find the sort by code that outputs a select element. It looks like this:

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

Change that to this (just adds an if statement):

<?php echo $this->__('Sort by') ?> <select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
    <?php if ($_order != 'Position') : // Remove "Position" from the sort option 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 for removing "Position" sort option ?>
<?php endforeach; ?>
</select>

And that all it takes. If anyone knows of a better/easier way to do it, please let me know.

2 Comments

AndyFebruary 14th, 2010 at 9:42 pm

Thank you . This was a big help. I have a quick question. Is there a way to change to sort order from asc to desc for just one category?

Josh PrattMarch 1st, 2010 at 10:48 pm

Andy,

Sure there is. You’ll have to do a check for the category you are wanting to reverse, then change the line that says ‘asc’ to ‘desc’.

Leave a comment

Your comment