Filtering with Custom Fields

Use Shopify Metafields to manage product attributes and enable flexible filtering

MetafieldFilterShopifyProduct Attributes
2 min read

What are Metafields?

Shopify Metafields allow you to add custom information to products. You can freely set attributes like "season," "target sport," or "material type" that aren't available by default.

Example Attributes

We set up attributes to match product characteristics:

Season
DescriptionSpring/Summer, Fall/Winter, All-season
Example ValuesSS, FW, ALL
Gender
DescriptionTarget gender
Example ValuesMen's, Women's, Unisex
Category
DescriptionProduct type
Example ValuesJacket, Pants, Helmet
Sport
DescriptionCompatible sport
Example ValuesMotorcycle, Ski, MTB

How Filter Processing Works

When customers select filters, the conditions are sent to the API. The API parses the conditions, converts them to Shopify's filter format, and retrieves the data.

Processing Steps

  1. URL parameter parsing: Read the conditions selected by customers
  2. Value normalization: Unify variations ("Men's", "Man" → "Man")
  3. Filter conversion: Transform to Shopify API-compatible format
  4. Data retrieval: Fetch matching products from Shopify

Server and Client Responsibilities

Processing all filters on the server would increase API calls. So we divide processing based on filter type.

Server-side Filters

  • Gender, season, category, sport type
  • Tag-based filtering
  • Stock availability

These are directly supported by Shopify API, so processing them server-side efficiently retrieves data.

Client-side Filters

  • Size (when multiple size systems exist)
  • Detailed price ranges
  • Specific stock conditions

Additional filtering is applied browser-side on retrieved data.

Handling Variations

The same meaning can have different data formats depending on how it was registered.

Example: "Men's", "Men", "Man", "Male"

We perform normalization to unify these. Filters work correctly regardless of how data was registered.

Architecture

Filter Conversion Flow
Customer selection
Season: Spring/Summer, Gender: Men's
URL parameters
?season=SS&gender=Man
Parameter parsing
season → "SS", gender → "Man"
Value normalization
"Men" → "Man", "Men's" → "Man"
Convert to Shopify API filter format
API-ready format
Fetch products via Storefront API
Return matching products

Summary

By using Metafields, we can add custom filter items not supported by default features. Combined with divided processing and variation handling, we achieve user-friendly and stable filter functionality.

Related Topics