Adding shop filters
Previously, you added the ability for buyers to sort the marketplace homepage by shop name. As your marketplace grows and features more merchant shops, you want to enable buyers to narrow down high volumes of content and surface only the most relevant shops.
In this tutorial, you'll learn how to add filter functionality for shops. You'll set up shop filtering by country, but you can follow a similar structure to provide filtering by other shop attributes.
What you'll learnAnchor link to section titled "What you'll learn"
After finishing this tutorial, you'll know how to do the following:
Save shop attributes to your database
Filter database queries by shop country
Add shop country queries to the internal GraphQL API
Add the filter to the marketplace homepage
RequirementsAnchor link to section titled "Requirements"
You've completed the tutorial for adding shop sort tutorial.
Add the filter to the marketplace homepageAnchor link to section titled "Add the filter to the marketplace homepage"
To add shop sort, your buyer-facing app needs to make a request to the Storefront API. The following requests the shop name using the
nameIsLike argument, and requests the shop's ID, domain, and a Storefront Access Token. The
country argument enables filtering shops by a specific country. The
shopCountries query returns a list of all the shop's' countries.
Your marketplace homepage might now look something the following: