Help Needed - Incomplete Product Fetching from Shopify Collection in Next.js

Topic summary

A developer is experiencing an issue where their Next.js application only fetches 7 products from a Shopify “pins-accessories” collection, despite more products being available. Other collections (shawls, scarves, khimars) fetch all products correctly.

Technical Setup:

  • Using Shopify Storefront API with GraphQL
  • Pagination implemented with first: 250 parameter
  • API returns hasNextPage: false after 7 products
  • Proper API permissions configured (unauthenticated_read_product_listings, unauthenticated_read_collection_listings)

Suggested Troubleshooting:
One community member recommended checking if products without images are being silently skipped by the images(first: 2) query parameter. They suggested removing image filters temporarily to verify total product count.

Current Status:
The discussion remains unresolved. The original poster has shifted focus, now seeking an expert referral to help complete their headless ecommerce store rather than continuing to debug the specific fetching issue.

Summarized with AI on October 26. AI used: claude-sonnet-4-5-20250929.

Hello everyone,

I’m facing a puzzling issue with fetching products from a Shopify collection in my Next.js application. Specifically, for my “pins-accessories” collection, only 7 products are being fetched, even though there are more products available in the collection. Other collections (like “shawls,” “scarves,” and “khimars”) fetch all their products without any issues. I’d really appreciate any insights or suggestions to help me resolve this!

Code Details:

I have a utility function getCollectionProducts in lib/shopify.ts that handles fetching products with pagination. Here’s a simplified version of it:

export async function getCollectionProducts(handle: string :disappointed_face: Promise<ProductCardData> {

// GraphQL query to fetch products from a collection by handle
const query = query CollectionProducts($handle: String!, $first: Int!) { collection(handle: $handle) { products(first: $first) { edges { node { id title handle priceRange { minVariantPrice { amount } } images(first: 2) { edges { node { url } } } } } pageInfo { hasNextPage endCursor } } } };

const variables = { handle, first: 250 }; // Fetch up to 250 products
const response = await shopifyFetch(query, variables); // Custom fetch function for Shopify API
const products = response.data.collection.products.edges.map(edge => edge.node);
return products; // Returns array of product data
}

This function is called in my page component at /pins-accessories/page.tsx:

const productsData = await getCollectionProducts(‘pins-accessories’);

The Problem:- For the “pins-accessories” collection, productsData.length is always 7, even though there are more products in the collection.
  • Other collections return all their products as expected.
  • In the Shopify admin, “pins-accessories” has more than 7 products, all published to the “Online Store” channel including 3 more channels and marked as available for sale.
  • Logs show: “Total products fetched from Shopify for pins-accessories: 7” and “Available products after filtering: 7”.
What I’ve Checked:- Collection Handle: Confirmed “pins-accessories” is correct and matches the Shopify admin (case-sensitive).
  • Product Status: All products in the collection are published and available for sale.
  • API Permissions: Token includes unauthenticated_read_product_listings and unauthenticated_read_collection_listings.
Observations:- The API response (data.collection.products.edges) contains only 7 items for “pins-accessories,” with no errors.
  • Pagination is implemented, but pageInfo.hasNextPage is false after the first 7 products, suggesting the API thinks that’s all there is.
  • Environment variables (API token, store URL) are correctly set in .env.local.
My Questions:1. Why is the Shopify Storefront API returning only 7 products for this specific collection?
  1. Could there be Shopify-side settings or filters (e.g., inventory, tags) limiting the results?
  2. What additional debugging steps can I take to pinpoint the cause?
Extra Context:- Using Next.js 13+ with App Router.
  • No errors in the API response or server logs.
  • The issue is isolated to “pins-accessories”; other collections work fine.

Any help or pointers would be greatly appreciated, thanks in advance!

Hi @Wasay907

See if you have any items in the “pins-accessories” collection without images as the images(first: 2) will skip them silently. Attempt also to remove filters such as pictures and then check total number. Load product using collection if required. products without stepped filtering in order to pinpoint that cause.

I want someone expert who can help me complete my headless ecommerce store, can you refer me someone?

1 Like