Skip to main content
Skip to main content

AdminProductTypesResource

This class is used to send requests to Admin Product Type API Routes. All its method are available in the JS Client under the medusa.admin.productTypes property.

All methods in this class require user authentication.

Product types are string values created when you create or update a product with a new type. Products can have one type, and products can share types. This allows admins to associate products with a type that can be used to filter products.

Methods

list

Retrieve a list of product types. The product types can be filtered by fields such as q or value passed in the query parameter. The product types can also be sorted or paginated.

Example

To list product types:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})

By default, only the first 20 records are retrieved. You can control pagination by specifying the limit and offset properties:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})

Parameters

customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Filters and pagination configurations to apply on the retrieved product types.

Returns

ResponsePromiseResponsePromise<AdminProductTypesListRes>Required
Resolves to the list of product types with pagination fields.
Was this section helpful?