Changing the “Position” text to “Default” in the “Sort By” dropdown on product listing page in Magento

In Magento Vanilla installation the products are sorted based on “Position” on the product listing page by default. You have the provision to configure the default sorting parameter from Magento admin. In Magento Vanilla installation admin the options available are –  “Best Value”, “Name”  and  “Price”. “Best Value” sorting is actually sorting by position.

Suggested articles: 

“name” and “price” are catalog attributes but “position” is not.

Open the file {{Magento_Root}}\app\code\core\Mage\Catalog\Model\Config.php and locate the function “getAttributeUsedForSortByArray” that returns the options that can be used for sorting the product, it has the following code:


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;
}

From this function it is clear that if in case you need to remove sorting by position then you will have to override the Catalog module model but if just you need to change the text then you can do it with the help of locale files.

Say you want to change the text “Position” to something else say “Default”. For that you do not need to make any change to code or override a model, just follow the below steps.

  1. Open the “Mage_Catalog.csv” locale file located at {{Magento_Root}}\app\locale\en_US\Mage_Catalog.csv
  2. Add the following  line at the end of file and save it
    “Position”,”Default”
  3. Clear the cache and refresh the page.

That’s all you have to do.

If you get a chance then have a look at these two functions:

getDefaultSortBy() – File: {{MAGENTO_ROOT}}\app\code\core\Mage\Catalog\Model\Category.php

getProductListDefaultSortBy() –  File:  {{Magento_Root}}\app\code\core\Mage\Catalog\Model\Config.php

Leave a Comment

Back to top