cancel
Showing results for 
Search instead for 
Did you mean: 

Change Text for "Sort by Position"

Change Text for "Sort by Position"

My client doesn't like the term "Position" when sorting in Category Listing pages. They would rather it say something like "Recommended" ... They want to keep the functionality (because they can front-load their own proprietary products ahead of other items they sell) but they just don't believe their customers understand what "position" means. I've considered using a language file to switch the words, but it would theoretically change ALL instances of the word. Are there any easy ways of doing this without impacting other areas that use the word "position"...
2 REPLIES 2

Re: Change Text for "Sort by Position"

Hello kitestop,

The word position is coming from model class. Please refer the file vendor/magento/module-catalog/Model/Config.php. Here you can get a function getAttributeUsedForSortByArray() 

    /**
     * Retrieve Attributes Used for Sort by as array
     * key = code, value = name
     *
     * @return array
     */
    public function getAttributeUsedForSortByArray()
    {
        $options = ['position' => __('Position')];
        foreach ($this->getAttributesUsedForSortBy() as $attribute) {
            /* @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
            $options[$attribute->getAttributeCode()] = $attribute->getStoreLabel();
        }

        return $options;
    }

You can override the above function in your module and change the term Position as per your requirement. Then flush the cache and check on frontend.

Hope it will help you. Smiley Happy

Re: Change Text for "Sort by Position"

I'm not sure if by 2.4.6 this has become easier, or if this has always been this easy...

Now, you can simply open (or create):

<mage_root>/app/design/frontend/<Theme_Vendor>/<Theme_Child>/i18n/en_GB.csv

(or whatever language you're using)

and add:

Position,Whatever

So in the case of this question, it would be:

Position,Recommended