## Browse Collections

Fetch all collections:

```ts
const collections = await commerce.collectionBrowse();
```

## Get a Collection

Fetch a single collection by ID or slug:

```ts
const collection = await commerce.collectionGet({
  idOrSlug: "summer-sale",
});
```

### Response

```ts
{
  id: "col_abc123",
  name: "Summer Sale",
  slug: "summer-sale",
  description: "Hot deals for the summer season",
  products: [...],
}
```

## Create a Collection

```ts
const collection = await commerce.collectionCreate({
  name: "New Arrivals",
  slug: "new-arrivals",
  description: "Fresh products just added to the store",
});
```

## Products in Collections

Use the `collectionSlug` parameter when browsing products to filter by collection:

```ts
const products = await commerce.productBrowse({
  collectionSlug: "summer-sale",
  limit: 20,
});
```

## Collections vs Categories

| | Collections | Categories |
|---|---|---|
| **Purpose** | Curated product groups | Hierarchical taxonomy |
| **Structure** | Flat list | Can be nested |
| **Use case** | "Staff Picks", "Sale" | "Clothing > T-Shirts" |
| **Management** | Manual product assignment | Product categorization |

Both can be used together – a product can belong to multiple collections and one or more categories.

## Import Memberships

Bulk-import collection-product memberships from a CSV file (e.g. WooCommerce/Shopify migration data). Idempotent across re-runs.

```ts
const result = await commerce.collectionImportMemberships({
  file: csvFile, // File or Blob
});
```

### Response

```ts
{
  ok: true,
  processed: 1000,
  inserted: 950,
  skipped_existing: 40,
  errors: [],
}
```