> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openbridge.shop/llms.txt
> Use this file to discover all available pages before exploring further.

# .collection()

> Filter products by collection

```javascript theme={null}
openbridge.products.list().collection(idOrHandle)
```

Filters products to only those in a specific collection.

## Parameters

| Param        | Type     | Required | Description              |
| ------------ | -------- | -------- | ------------------------ |
| `idOrHandle` | `string` | Yes      | Collection handle or GID |

### Supported formats

| Format      | Example                                   |
| ----------- | ----------------------------------------- |
| Handle      | `'summer-sale'`                           |
| Shopify GID | `'gid://shopify/Collection/448629506282'` |

## Returns

`ProductListBuilder` (chainable)

## Examples

### By handle

```javascript theme={null}
const { items } = await openbridge.products.list().collection('summer-sale')
```

### By GID

```javascript theme={null}
const { items } = await openbridge.products
    .list()
    .collection('gid://shopify/Collection/448629506282')
```

### With limit

```javascript theme={null}
const { items } = await openbridge.products
    .list()
    .collection('new-arrivals')
    .limit(8)
```

### With field selection

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

### Paginate collection

```javascript theme={null}
const page1 = await openbridge.products.list().collection('all').limit(12)

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