How to show products on a collection when I've the variable Ids

Topic summary

Goal: Display products in a collection when only variant IDs are available, ideally using Liquid in a Shopify theme.

Key clarification: The IDs are variant IDs (not variables). The requester wants to list products corresponding to those variant IDs.

Current approach: Fetching products via the Shopify GraphQL API from a in Liquid, which exposes the X-Shopify-Access-Token. The JS needed to assemble product data on a pre-built theme is becoming messy.

Suggestion offered: Create a manual collection and add the specific products, rather than relying on an automatic collection. This does not directly address mapping from variant IDs to products.

Technical context: Liquid is Shopify’s templating language; variant IDs uniquely identify product variants; the X‑Shopify‑Access‑Token is a private API credential and should not be exposed client-side.

Status: No solution provided yet for a Liquid-only or more secure method to derive products from variant IDs. Open questions: How to map variant IDs to products in Liquid, and how to avoid exposing API credentials while reducing JS complexity.

Summarized with AI on January 3. AI used: gpt-5.
  • I have a list of variable ids.

  • I want to show a list of these products.

  • I’m new to shopify theme development, please suggest me the liquid code if it’s possible.

Hi there @SazzadSowmik

If i assume you want to show some specific products in the collection write? for that you can create collection and add those products manually instead of automatic

Sorry for the mistype. It is varinat IDs, I have variant ids, not variable ids. I want to show the list of products co-responding to the variant ids,
I am currently getting the product via graphQL api from the liquid code inside tag, which expose my X-Shopify-Access-Token . Then getting the necessary details and building a structure with JS which is becoming so messy on a pre-built theme. I’m curious about any better way..