Updated Default Sort Order

Updated Default Sort Order

TKEQShop
Tourist
4 0 1

Is anyone else struggling with the updated Default Sort Order that changed from Alphabetical to Newest Created on Feb 5/2025? Shopify support is telling me there is no way to change my default sort order back to Alphabetical - the best recommendation they offered was to hire a third party to change the code in the back end to customize my Shopify site. I'm frustrated with the recommendation that I need to spend more money to have my shop set up the way that works for me. 

Replies 6 (6)

ES1
Shopify Partner
261 25 30

Hi @TKEQShop ,

 

You may need to make a small change in the code to get this done:

 

Add Custom Code to Change Default Sort Order

  1. Go to the Theme Editor:

    • In Shopify Admin, navigate to Online Store > Themes.
    • Click Actions > Edit Code for your active theme.
  2. Locate the Collection Template:

    • Open the collection.liquid file (or main-collection.liquid in Dawn and other modern themes).
  3. Find the Sort Order Code:

    • Look for code like {% assign sorted_products = collection.products %} or collection.products | sort
    • Replace with {% assign sorted_products = collection.products | sort: 'title' %}
  4. Save, this should fix it for you.

 

You can also use apps such as Collection Sort by Power Tools or Smart Collection Filters & Search to have more control on your filtering.

If this fixed your issue, Please Like and Accept as a Solution.
Looking for assistance? Hire an experienced Shopify Partner! Visit EcommerceStorez.us today for a quick quote.
Seeking an elegant theme designed to boost conversions? Explore our High-Converting Shopify Themes today!

TheUntechnickle
Shopify Partner
539 65 158

Hey @TKEQShop,

You can modify your Shopify theme to automatically sort products alphabetically by adding a small code snippet to your theme files. This ensures a consistent alphabetical sorting experience without requiring ongoing maintenance or third-party apps.

 

The solution involves adding either a JavaScript snippet to your theme.liquid file or a Liquid-based solution to your collection-template.liquid file. This modification automatically redirects visitors to an alphabetically sorted view when they land on your collection pages.

How to Implement:

  1. Go to Online Store > Themes
  2. Click "Actions" > "Edit Code"
  3. Find your theme.liquid file
  4. Add the provided JavaScript snippet just before the closing </head> tag
  5. Save your changes

I’m sharing this because such basic functionality shouldn’t require hiring a developer or paying for an app. While Shopify’s decision to change the default sorting behavior makes sense in some cases, restoring alphabetical sorting should be simple and accessible.

JavaScript Solution (Add to theme.liquid just before </head>)

<script>
document.addEventListener('DOMContentLoaded', function() {
  // Check if the current page is a collection page
  if (window.location.pathname.includes('/collections/')) {
    // Get the current sorting parameter
    const urlParams = new URLSearchParams(window.location.search);
    const currentSort = urlParams.get('sort_by');
    
    // Redirect to alphabetical sorting if no sort parameter is set
    if (!currentSort) {
      window.location.href = window.location.pathname + '?sort_by=title-ascending';
    }
  }
});
</script>

Alternative Liquid Solution (Add to collection-template.liquid)

{% if collection.sort_by == blank %}
  <script>
    window.location.href = '{{ collection.url }}?sort_by=title-ascending';
  </script>
{% endif %}

 

This quick fix restores alphabetical sorting without the need for third-party solutions or ongoing maintenance.

 

Cheers!
Shubham | Untechnickle

Helping for free: hello@untechnickle.com


Don't forget to say thanks, it'll make my day - just send me an email! 


Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App

TKEQShop
Tourist
4 0 1

Thank you so much for this - to confirm this is to do with my products page on my Shopify Account - I don't have any problems with how things are appearing to my customers. This is more an internal problem. I will give this a try if so 🙂 

 

TheUntechnickle
Shopify Partner
539 65 158

Hi Natalie,

 

Thank you for your follow-up email! I hope you're doing fantastic.

 

Please ignore my previous solution - ;et me offer you a simple, free solution that affects only your backend admin panel - not your customer-facing store. This method uses a browser extension called Tampermonkey to automatically sort your products alphabetically in the admin panel.

 

1. Install the Tampermonkey Extension:


2. Add the Sorting Script:

  • Click the Tampermonkey icon in your browser (it looks like a black square with two circles).
  • Select "Create a new script".
  • Delete any default code in the editor.
  • Copy and paste the following code:
// ==UserScript==
// @name         Shopify Admin Automatic Alphabetical Sort
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Automatically sort Shopify admin product list alphabetically
// @author       You
// @match        https://admin.shopify.com/store/*/products*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function sortProductsAlphabetically() {
        const tableBody = document.querySelector('.Polaris-IndexTable__Table tbody');
        if (!tableBody) {
            console.log('Table body not found, waiting...');
            return false;
        }

        const rows = Array.from(tableBody.querySelectorAll('tr[id^="gid://shopify/Product/"]'));
        if (rows.length <= 1) {
            console.log('Not enough rows to sort');
            return false;
        }

        rows.sort((a, b) => {
            const titleA = a.querySelector('a[data-primary-link="true"] span')?.textContent.trim().toLowerCase() || '';
            const titleB = b.querySelector('a[data-primary-link="true"] span')?.textContent.trim().toLowerCase() || '';
            return titleA.localeCompare(titleB);
        });

        rows.forEach(row => tableBody.appendChild(row));
        return true;
    }

    function observeProductList() {
        const productTable = document.querySelector('.Polaris-IndexTable');
        if (!productTable) {
            setTimeout(observeProductList, 1000);
            return;
        }

        const observer = new MutationObserver((mutations) => {
            setTimeout(() => {
                sortProductsAlphabetically();
            }, 500);
        });

        observer.observe(productTable, {
            childList: true,
            subtree: true
        });

        sortProductsAlphabetically();
    }

    function attemptInitialSort(attempts = 0) {
        if (attempts > 10) return;
        
        if (!sortProductsAlphabetically()) {
            setTimeout(() => attemptInitialSort(attempts + 1), 1000);
        } else {
            observeProductList();
        }
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', () => attemptInitialSort());
    } else {
        attemptInitialSort();
    }

    window.addEventListener('popstate', () => attemptInitialSort());
    window.addEventListener('pushstate', () => attemptInitialSort());
    window.addEventListener('replacestate', () => attemptInitialSort());
})();

3. Save the Script:

  • Click File > Save, or press Ctrl+S (Cmd+S on Mac).
  • Refresh your Shopify admin products page.

Summary:

  • Scope: This script only affects how products are displayed in your admin panel.
  • Impact: It does not change anything on your customer-facing store.
  • Automation: Products are automatically sorted alphabetically every time you view them.
  • Compatibility: It works across all product views (All, Active, Draft, etc.).
  • Ease of Use: No coding knowledge or paid services are required.

If you ever want to disable the alphabetical sorting, simply:

  1. Click the Tampermonkey icon.
  2. Toggle the switch next to "Shopify Admin Automatic Alphabetical Sort".

Please let me know if you need any help with the installation or have any questions, I’m happy to clarify any steps or assist with troubleshooting.

 

Best regards,

Shubham | Untechnickle

P.S. Remember to refresh your Shopify admin page after installing the script for the changes to take effect.

Helping for free: hello@untechnickle.com


Don't forget to say thanks, it'll make my day - just send me an email! 


Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App

littlewhimsy
Excursionist
20 0 12

I second this I am getting so frustrated for the new automatic sort order in the admin for products and also for purchase orders. Shopify there needs to be a way for us to set our preferences for the default sort order the new ones are wasting our time having to resort every time we use these pages.

mexicanplum
Visitor
1 0 0

Yes! This is so frustrating. I don't understand why this change was made to begin with, when alphabetical order should always be the default.