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.

This entry was posted in Magento, PHP. Bookmark the permalink.

7 Responses to Magento: How To Remove The "Position" Sort Option

  1. Andy says:

    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?

  2. Mrnl says:

    I am working on a local host to test if i want to start a shop and i can design it. I have a question for U.

    If u make attributes for products they come in additional information, now i have implemented a video and made a new tab for it, but the video keeps showing up in additional also and i do not want that. Do you know how i can fix it.

    thanks.

    • Josh Pratt says:

      Mrnl,

      The reason it is showing up in the Additional Information is most likely because for that attribute you have “Yes” selected for the “Visible on Product View Page on Front-end” option. You need to turn that to “No”.

  3. Mrnl says:

    Hi Josh Pratt,

    Just looking at your site again.
    And saw that you answered my question. tried it and it works.
    Thanks very much.
    That a simple yes or no can make so much difference.

    Maybe an idea for you , when you or someone else answers a comment that the people who left a comment get an e-mail.

  4. toniyecla says:

    in 1.4, you can try to comment this in app/code/core/Mage/Catalog/Model/Config.php:

    public function getAttributeUsedForSortByArray()
    {
    $options = array(
    // ‘position’ => Mage::helper(‘catalog’)->__(‘Position’)
    );
    foreach ($this->getAttributesUsedForSortBy() as $attribute) {
    /* @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */
    $options[$attribute->getAttributeCode()] = $attribute->getStoreLabel();
    }

    return $options;
    }

    • Josh Pratt says:

      I do not suggest doing the above (DO NOT EDIT CORE CODE).

      At a bare minimum, move the above mentioned file to app/code/local/Mage/Catalog/Model/Config.php and then make the edit.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">