Skip to main content
shoppy.products.collection(idOrHandle)
Filters products to only those in a specific collection.
This is a chainable method. Call .list() to execute.

Parameters

ParamTypeRequiredDescription
idOrHandlestringYesCollection handle or GID

Supported formats

FormatExample
Handle'summer-sale'
Shopify GID'gid://shopify/Collection/448629506282'

Returns

ProductsQueryBuilder (chainable)

Examples

By handle

const { items } = await shoppy.products.collection('summer-sale').list()

By GID

const { items } = await shoppy.products
    .collection('gid://shopify/Collection/448629506282')
    .list()

With limit

const { items } = await shoppy.products
    .collection('new-arrivals')
    .limit(8)
    .list()

With field selection

const { items } = await shoppy.products
    .collection('sale')
    .limit(12)
    .select([
        'title',
        'handle',
        'priceRange',
        'compareAtPriceRange',
        'featuredImage'
    ])
    .list()

Paginate collection

const page1 = await shoppy.products.collection('all').limit(12).list()

if (page1.pageInfo.hasNextPage) {
    const page2 = await shoppy.products
        .collection('all')
        .limit(12)
        .after(page1.pageInfo.endCursor)
        .list()
}