Filter collections directly from menu links?

Solved

Filter collections directly from menu links?

NoNameNoSlogan
Tourist
4 0 2
 

I'm setting up a Shopify shop that could potentially have a LOT of collections, but I'm hoping there's a better way to organise things...

 

Example: I'd like to set up a collection called 'Brakes'. This collection would have every product tagged with brakes in it. But I need to filter that category further by Car Model in the menu system without having to create loads of extra theme templates.

 

At the moment I have this structure:

  • Car Model A Collection > Car Model A Brakes Collection
  • Car Model B Collection > Car Model B Brakes Collection
  • Car Model C Collection > Car Model C Brakes Collection Etc.

What I'd like to do is:

  • Car Model A Collection > Brakes Collection (filtered by Car Model A tags)
  • Car Model B Collection > Brakes Collection (filtered by Car Model B tags)
  • Car Model C Collection > Brakes Collection (filtered by Car Model C tags) Etc.

That way I only need one Collection for Brakes instead of separate ones for each Car Model. This should surely be easy, but I can't seem to find a way...

 

I'm using the version 2.0

Accepted Solution (1)

Elizabeth_craig
Shopify Partner
13 2 9

This is an accepted solution.

When you set up your navigation links, you can input any URL. This is how you could link to a filtered collection. Assuming you have your filters set up with the new Shopify Search & Discovery App, here's an example.

 

Example:

Collection title: all,

Filtered by: filter.p.m.product.collections=Books

Link for navigation: /collections/all?filter.p.m.product.collections=Books

 

You can get the filter url by navigating to your collection and applying the filters you want. 

Or, you can get the filter url by following Shopify's URL parameter structure. But I think it would be easier to just copy and paste the filter url.

 

The above example filter uses m for metafields, where my metafield namespace is product, key is collections, and value is Books. If you filter by product type, the url will look like this: 

 /collections/all?filter.p.product_type=Book

 

Just make sure to click the suggested link that pops up when inputting the menu link manually. 

Elizabeth_craig_1-1661408375928.png

 

I hope that helps!

 

View solution in original post

Replies 8 (8)

SmallTask
Shopify Partner
973 41 55

Hello @NoNameNoSlogan 

 

You can configure filter apps on the collection page.

banned
NoNameNoSlogan
Tourist
4 0 2

Thanks for the reply.

 

I probably haven't explained myself properly.

 

I have a template page dedicated to each category and sub category, and I'm using filters on the pages. I'd just like a way to pass a condition from one collection page to the next... it would be something like: Car Model links to brakes?filter=brake-discs

 

Elizabeth_craig
Shopify Partner
13 2 9

This is an accepted solution.

When you set up your navigation links, you can input any URL. This is how you could link to a filtered collection. Assuming you have your filters set up with the new Shopify Search & Discovery App, here's an example.

 

Example:

Collection title: all,

Filtered by: filter.p.m.product.collections=Books

Link for navigation: /collections/all?filter.p.m.product.collections=Books

 

You can get the filter url by navigating to your collection and applying the filters you want. 

Or, you can get the filter url by following Shopify's URL parameter structure. But I think it would be easier to just copy and paste the filter url.

 

The above example filter uses m for metafields, where my metafield namespace is product, key is collections, and value is Books. If you filter by product type, the url will look like this: 

 /collections/all?filter.p.product_type=Book

 

Just make sure to click the suggested link that pops up when inputting the menu link manually. 

Elizabeth_craig_1-1661408375928.png

 

I hope that helps!

 

NoNameNoSlogan
Tourist
4 0 2

Thank you so much, Elizabeth.

That's a great solution and very clearly explained 🙂

JorgeBriceno
Shopify Partner
1 0 0

Hi Elizabeth, This is a good workaround since Shopify still has tag filter options on the navigation menu instead of the new filter types. Is there a way to make this link open on the same tab and not a new tab?

Thanks!

Elizabeth_craig
Shopify Partner
13 2 9

Hello!

 

This alone shouldn’t affect how your links are opening. Links will open in a new tab when they have 

target="_blank"

 within the href element, like: 

<a href="https://www.freecodecamp.org/" target="_blank" rel="noopener noreferrer">freeCodeCamp</a>


Hope that is helpful!

 

I have also encountered a seemingly random problem where all of the links on a site containing a blog section were being forced to open in a new tab. This was a hard bug to track down, but ended up being related to some funny business in the blog excerpt! I didn’t find it until looking at the <> code of the blog excerpt. Hope that is helpful to anyone searching for an answer. 

PatternSymphony
Visitor
1 0 0

How would this affect SEO? I've read that Google doesn't like dynamic URLs.

Elizabeth_craig
Shopify Partner
13 2 9

This should not affect seo. I found this article helpful: https://developers.google.com/search/blog/2008/09/dynamic-urls-vs-static-urls