Hello Shopify Developer,
I am facing an issue with filtering products in Shopify using URL paths (query parameters).
I have this URL:
https://kapaasfabrics.com/collections/all?filter=poplin
In this case, poplin is a filter value, and I want to display only those products that belong to the Poplin collection / filter.
I also have another URL:
https://kapaasfabrics.com/collections/all?categories=men&filter=poplin
In this case:
Here, I want to display only those products that:
In other words, only the common products between the Men and Poplin collections should be displayed on the frontend.
Hey Tushar so….this is in New GraphQL Product APIscategory of the forum which makes entirely no sense at all dude with the context here.
Real Quick Buddy:
Where did you figure that is how you filter via URL at all? The URL param system you are showing would be 100% custom and you would need to figure out how to make that work.
Breaking Apart Your Params:
Categories:
categories even as an approach is a little “what are you thinking dude?”. if you want the products of a specific collection use that collection url /collections/mens. However, If you want to leverage some kind of custom category field to determine overlap you would need to have to a Product level metafieldof type list.single_line_text such as Categories so you can filter against it where you would just enter info like Mens Youth Poplin etc. Unfortunately, you can’t just naturally filter by overlapping collections, and I kind of understand why because not all collections are meant to be exactly exposed and accessible even if they are on a given sales channel.
Filter:
When it comes to your actual filter, you don’t do that. First up set up filterable data in the Search and Discovery app.
An actual filter URL would look like: filter.p.m.custom.department=Home where we have filter (what we are doing) p (the level product p or variant v). Then we get to the field. If it’s a product option you do filter.p.options.size=value, if it is a metafield you do filter.p.m.namespace.key=value
What This Could Look Like:
So let’s say you get your tin cans in a line. Most likely the URL you would end up with would be
/collections/all?filter.p.m.custom.categories=Men&filter.p.m.custom.categories=Poplin, this requires the Product to have a text list metafield called Categories with the namespace Custom. This would be somewhat annoying to keep up to date since it is not automated and lists have a limit of 128 items last time I checked.
Still Confused:
Once again, where did you learn that would be a possible URL parameter set???