Displaying WooCommerce Products in Swedish Alphabetical Order

In a recent Business Bloomer Club discussion, a member shared a challenge with displaying product titles alphabetically according to Swedish standards in WooCommerce.

By default, WooCommerce sorts letters like å, ä, and ö before “A,” which doesn’t match the Swedish alphabetical order, where they should appear at the end. Efforts to adjust the database settings directly didn’t resolve the issue, even after disabling plugins and testing with the Storefront theme.

This scenario highlights a common hurdle for WooCommerce users working with international character sorting. Below is a breakdown of the troubleshooting steps taken and the eventual solution.

Troubleshooting Steps and Findings

  1. Plugin and Theme Testing: The member disabled all plugins and enabled WooCommerce’s default theme, Storefront, to rule out theme/plugin conflicts. The sorting issue persisted, suggesting a WooCommerce or database-level problem.
  2. Community Suggestions: Suggestions included using database collation settings to sort based on Swedish alphabetical standards. However, basic adjustments like altering the database collation didn’t resolve the issue.
  3. WooCommerce Bug Report: The user reported the issue on WooCommerce’s GitHub for further support. This approach is essential when default settings don’t align with localized requirements.

Solution: Custom Database Collation

A WooCommerce GitHub contributor shared a custom solution involving a MySQL collation update specifically for Swedish. Here’s the solution that worked:

add_action( 'init', function () {
    global $wpdb;
    $wpdb->query( "
        ALTER TABLE $wpdb->posts
        MODIFY post_title TEXT COLLATE utf8mb4_swedish_ci
    " );
} );

How It Works

This snippet modifies the post_title column in the database, assigning a Swedish-specific collation (utf8mb4_swedish_ci) that correctly orders special characters according to Swedish alphabetical standards.

Final Thoughts

International WooCommerce stores frequently encounter challenges like this due to regional variations in sorting and character treatment. If your product titles don’t sort correctly by default, customizing database collation can provide a precise, long-term solution.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

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