Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello everyone,
I would like to ask for help. I'm trying to organize the 'Products' (Shop) section of my site using filters.
Since this is not a collection but a default page and I can't change the filters, I can't set how the products are displayed. This problem only occurs on the 'Shop' page of my site. If I click on it and go to view the products, I notice that they are ordered alphabetically from A to Z.
However, I would like to show them directly based on "best sellers".
Here is the direct link to the Shop page of my site: https://a3cd78.myshopify.com/collections/all
Does anyone know how I can solve this problem?
Thank you
Hi there,
So there is a little bit of a trick here. All you have to do is create a new collection, name it however you like and ensure that all the products are loaded in. Then simply make the settings on how you would like them and update the "shop" navigation link to this collection you have just created.
Hope this helps!
Hi, yes, but the problem is that when creating a collection I always have to manually import all the products
Hi there,
You actually don't, you can simply do it based on tag or another variable. Also, you can actually edit the "all products" collection to sort on best selling by default 😉
Here is the way to make 'Best Selling' filter as default:
Use below code:
<script>
let shopifymode = Shopify.designMode;
let maincollection = '{{ template.name }}';
let currentUrl = window.location.href;
if (maincollection === 'collection' && shopifymode === undefined) {
if (!currentUrl.includes('sort_by=')) {
// Create the new URL properly
let newUrl;
if (currentUrl.includes('?')) {
// If URL already has query parameters, append with &
newUrl = currentUrl + '&sort_by=best-selling';
} else {
// If no existing parameters, add with ?
newUrl = currentUrl + '?sort_by=best-selling';
}
// Force page reload with the new URL
window.location.replace(newUrl);
}
}
</script>