Skip to main content
Skip to main content

ProductTagsResource

This class is used to send requests to Store Product Tag API Routes. All its method are available in the JS Client under the medusa.productTags property.

Product tags are string values that can be used to filter products by. Products can have more than one tag, and products can share tags.

Methods

list

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

Example

To list product tags:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.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 })
medusa.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})

Parameters

Filters and pagination configurations to apply on the retrieved product tags.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

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