Skip to main content
Skip to main content

Product Tags

Queries and Mutations listed here are used to send requests to the Admin Product Tag API Routes.

All hooks listed require user authentication.

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

Queries

useAdminProductTags

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

Example

To list product tags:

import React from "react"
import { useAdminProductTags } from "medusa-react"

function ProductTags() {
const {
product_tags,
isLoading
} = useAdminProductTags()

return (
<div>
{isLoading && <span>Loading...</span>}
{product_tags && !product_tags.length && (
<span>No Product Tags</span>
)}
{product_tags && product_tags.length > 0 && (
<ul>
{product_tags.map(
(tag) => (
<li key={tag.id}>{tag.value}</li>
)
)}
</ul>
)}
</div>
)
}

export default ProductTags

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

import React from "react"
import { useAdminProductTags } from "medusa-react"

function ProductTags() {
const {
product_tags,
limit,
offset,
isLoading
} = useAdminProductTags({
limit: 20,
offset: 0
})

return (
<div>
{isLoading && <span>Loading...</span>}
{product_tags && !product_tags.length && (
<span>No Product Tags</span>
)}
{product_tags && product_tags.length > 0 && (
<ul>
{product_tags.map(
(tag) => (
<li key={tag.id}>{tag.value}</li>
)
)}
</ul>
)}
</div>
)
}

export default ProductTags

Hook Parameters

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

Query Returned Data

limitnumberRequired
The maximum number of items that can be returned in the list.
offsetnumberRequired
The number of items skipped before the returned items in the list.
countnumberRequired
The total number of items available.
product_tagsProductTag[]Required
An array of product tag details.
Was this section helpful?