---
displayed_sidebar: productReference
badge:
  variant: orange
  text: Beta
slug: /references/product/retrieveCollection
sidebar_label: retrieveCollection
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# retrieveCollection - Product Module Reference

This documentation provides a reference to the retrieveCollection method. This belongs to the Product Module.

This method is used to retrieve a product collection by its ID.

## Example

A simple example that retrieves a product collection by its ID:

```ts
import {
  initialize as initializeProductModule,
} from "@medusajs/product"

async function retrieveCollection (id: string) {
  const productModule = await initializeProductModule()

  const collection = await productModule.retrieveCollection(id)

  // do something with the product collection or return it
}
```

To specify relations that should be retrieved:

```ts
import {
  initialize as initializeProductModule,
} from "@medusajs/product"

async function retrieveCollection (id: string) {
  const productModule = await initializeProductModule()

  const collection = await productModule.retrieveCollection(id, {
    relations: ["products"]
  })

  // do something with the product collection or return it
}
```

## Parameters

<ParameterTypes parameters={[
  {
    "name": "productCollectionId",
    "type": "`string`",
    "description": "The ID of the product collection to retrieve.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../../product/interfaces/product.FindConfig.mdx)&#60;[ProductCollectionDTO](../../product/interfaces/product.ProductCollectionDTO.mdx)&#62;",
    "description": "The configurations determining how the product collection is retrieved. Its properties, such as `select` or `relations`, accept the\nattributes or relations associated with a product collection.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "order",
        "type": "`object`",
        "description": "An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "relations",
        "type": "`string`[]",
        "description": "An array of strings, each being relation names of the entity to retrieve in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "select",
        "type": "(`string` \\| keyof `Entity`)[]",
        "description": "An array of strings, each being attribute names of the entity to retrieve in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "skip",
        "type": "`null` \\| `number`",
        "description": "A number indicating the number of records to skip before retrieving the results.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "take",
        "type": "`null` \\| `number`",
        "description": "A number indicating the number of records to return in the result.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "withDeleted",
        "type": "`boolean`",
        "description": "A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "sharedContext",
    "type": "[Context](../../product/interfaces/product.Context.mdx)",
    "description": "A context used to share resources, such as transaction manager, between the application and the module.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "enableNestedTransactions",
        "type": "`boolean`",
        "description": "A boolean value indicating whether nested transactions are enabled.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "isolationLevel",
        "type": "`string`",
        "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "manager",
        "type": "`TManager`",
        "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionId",
        "type": "`string`",
        "description": "A string indicating the ID of the current transaction.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionManager",
        "type": "`TManager`",
        "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />

## Returns

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ProductCollectionDTO](../../product/interfaces/product.ProductCollectionDTO.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "The retrieved product collection.",
    "expandable": false,
    "children": [
      {
        "name": "deleted_at",
        "type": "`string` \\| `Date`",
        "description": "When the product collection was deleted.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "handle",
        "type": "`string`",
        "description": "The handle of the product collection. The handle can be used to create slug URL paths.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "id",
        "type": "`string`",
        "description": "The ID of the product collection.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "metadata",
        "type": "`null` \\| `Record<string, unknown>`",
        "description": "Holds custom data in key-value pairs.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "products",
        "type": "[ProductDTO](../../product/interfaces/product.ProductDTO.mdx)[]",
        "description": "The associated products.",
        "optional": true,
        "defaultValue": "",
        "expandable": true,
        "children": [
          {
            "name": "categories",
            "type": "`null` \\| [ProductCategoryDTO](../../product/interfaces/product.ProductCategoryDTO.mdx)[]",
            "description": "The associated product categories.",
            "optional": true,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "collection",
            "type": "[ProductCollectionDTO](../../product/interfaces/product.ProductCollectionDTO.mdx)",
            "description": "The associated product collection.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "created_at",
            "type": "`string` \\| `Date`",
            "description": "When the product was created.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "deleted_at",
            "type": "`string` \\| `Date`",
            "description": "When the product was deleted.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "description",
            "type": "`null` \\| `string`",
            "description": "The description of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "discountable",
            "type": "`boolean`",
            "description": "Whether the product can be discounted.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "external_id",
            "type": "`null` \\| `string`",
            "description": "The ID of the product in an external system. This is useful if you're integrating the product with a third-party service and want to maintain\na reference to the ID in the integrated service.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "handle",
            "type": "`null` \\| `string`",
            "description": "The handle of the product. The handle can be used to create slug URL paths.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "height",
            "type": "`null` \\| `number`",
            "description": "The height of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "hs_code",
            "type": "`null` \\| `string`",
            "description": "The HS Code of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "id",
            "type": "`string`",
            "description": "The ID of the product.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "images",
            "type": "[ProductImageDTO](../../product/interfaces/product.ProductImageDTO.mdx)[]",
            "description": "The associated product images.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "is_giftcard",
            "type": "`boolean`",
            "description": "Whether the product is a gift card.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "length",
            "type": "`null` \\| `number`",
            "description": "The length of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "material",
            "type": "`null` \\| `string`",
            "description": "The material of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "metadata",
            "type": "`Record<string, unknown>`",
            "description": "Holds custom data in key-value pairs.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "mid_code",
            "type": "`null` \\| `string`",
            "description": "The MID Code of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "options",
            "type": "[ProductOptionDTO](../../product/interfaces/product.ProductOptionDTO.mdx)[]",
            "description": "The associated product options.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "origin_country",
            "type": "`null` \\| `string`",
            "description": "The origin country of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "status",
            "type": "[ProductStatus](../../product/enums/product.ProductStatus.mdx)",
            "description": "The status of the product.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "subtitle",
            "type": "`null` \\| `string`",
            "description": "The subttle of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "tags",
            "type": "[ProductTagDTO](../../product/interfaces/product.ProductTagDTO.mdx)[]",
            "description": "The associated product tags.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "thumbnail",
            "type": "`null` \\| `string`",
            "description": "The URL of the product's thumbnail.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "title",
            "type": "`string`",
            "description": "The title of the product.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "type",
            "type": "[ProductTypeDTO](../../product/interfaces/product.ProductTypeDTO.mdx)[]",
            "description": "The associated product type.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "updated_at",
            "type": "`string` \\| `Date`",
            "description": "When the product was updated.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "variants",
            "type": "[ProductVariantDTO](../../product/interfaces/product.ProductVariantDTO.mdx)[]",
            "description": "The associated product variants.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": []
          },
          {
            "name": "weight",
            "type": "`null` \\| `number`",
            "description": "The weight of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "width",
            "type": "`null` \\| `number`",
            "description": "The width of the product.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "title",
        "type": "`string`",
        "description": "The title of the product collection.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />
