docs: fixes to product category how-to and overview (#3702)
This commit is contained in:
@@ -34,7 +34,7 @@ Admins can manage unlimited amount of products and their variants. They can mana
|
||||
{
|
||||
type: 'link',
|
||||
href: '/user-guide/products/manage',
|
||||
label: 'User Guide: Manage Products',
|
||||
label: 'User Guide: Products',
|
||||
customProps: {
|
||||
icon: Icons['users-solid'],
|
||||
description: 'Manage products in Medusa Admin.'
|
||||
@@ -66,13 +66,12 @@ Customers can use this organization to filter products while browsing them.
|
||||
customProps: {
|
||||
icon: Icons['academic-cap-solid'],
|
||||
description: 'Learn how to manage categories using Admin APIs.',
|
||||
isSoon: true,
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
href: '/user-guide/products/categories',
|
||||
label: 'User Guide: Manage Categories',
|
||||
label: 'User Guide: Categories',
|
||||
customProps: {
|
||||
icon: Icons['users-solid'],
|
||||
description: 'Learn how to manage categories in the Medusa Admin.'
|
||||
|
||||
@@ -49,6 +49,9 @@ If you follow the Medusa React code blocks, it's assumed you already have [Medus
|
||||
|
||||
You can list product categories by sending a request to the [List Product Categories endpoint](/api/store#tag/Product-Category/operation/GetProductCategories):
|
||||
|
||||
<Tabs groupId="request-type" wrapperClassName="code-tabs">
|
||||
<TabItem value="client" label="Medusa JS Client" default>
|
||||
|
||||
```ts
|
||||
medusa.productCategories.list()
|
||||
.then(({ product_categories, limit, offset, count }) => {
|
||||
@@ -56,6 +59,9 @@ medusa.productCategories.list()
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="medusa-react" label="Medusa React">
|
||||
|
||||
```tsx
|
||||
import { useProductCategories } from "medusa-react"
|
||||
import { ProductCategory } from "@medusajs/medusa"
|
||||
@@ -88,8 +94,11 @@ function Categories() {
|
||||
export default Categories
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
```ts
|
||||
fetch(`<BACKEND_URL>/product-categories`, {
|
||||
fetch(`<BACKEND_URL>/store/product-categories`, {
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
@@ -98,11 +107,17 @@ fetch(`<BACKEND_URL>/product-categories`, {
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```bash
|
||||
curl -L -X GET '<BACKEND_URL>/store/product-categories' \
|
||||
-H 'Authorization: Bearer <API_TOKEN>'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
This request does not require any query parameters. You can, however, pass query parameters to filter the list of categories, such as the passing the `q` query parameter to search categories by title or handle. You can learn about available query parameters in the [API reference](/api/store#tag/Product-Category/operation/GetProductCategories).
|
||||
|
||||
The request returns an array of product categories along with [pagination fields](/api/store#section/Pagination).
|
||||
@@ -117,6 +132,9 @@ By default, the categories are not retrieved along with their nested children. T
|
||||
|
||||
You can retrieve a single product category by using the [Get a Product Category endpoint](/api/store#tag/Product-Category/operation/GetProductCategoriesCategory):
|
||||
|
||||
<Tabs groupId="request-type" wrapperClassName="code-tabs">
|
||||
<TabItem value="client" label="Medusa JS Client" default>
|
||||
|
||||
```ts
|
||||
medusa.productCategories.retrieve(productCategoryId)
|
||||
.then(({ product_category }) => {
|
||||
@@ -124,6 +142,9 @@ medusa.productCategories.retrieve(productCategoryId)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="medusa-react" label="Medusa React">
|
||||
|
||||
```tsx
|
||||
import { useProductCategory } from "medusa-react"
|
||||
|
||||
@@ -141,8 +162,13 @@ function Category() {
|
||||
export default Category
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="fetch" label="Fetch API">
|
||||
|
||||
<!-- eslint-disable max-len -->
|
||||
|
||||
```ts
|
||||
fetch(`<BACKEND_URL>/product-categories/${productCategoryId}`, {
|
||||
fetch(`<BACKEND_URL>/store/product-categories/${productCategoryId}`, {
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
@@ -151,11 +177,17 @@ fetch(`<BACKEND_URL>/product-categories/${productCategoryId}`, {
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```bash
|
||||
curl -L -X GET '<BACKEND_URL>/store/product-categories/<CAT_ID>' \
|
||||
-H 'Authorization: Bearer <API_TOKEN>'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
This request requires the product category ID as a path parameter. You can also pass query parameters such as `expand` and `fields` as explained in the [API reference](/api/store#tag/Product-Category/operation/GetProductCategoriesCategory).
|
||||
|
||||
The request returns the category as an object.
|
||||
@@ -164,4 +196,4 @@ The request returns the category as an object.
|
||||
|
||||
## See Also
|
||||
|
||||
- [How to manage product categories](../admin/manage-categories.mdx).
|
||||
- [How to manage product categories](../admin/manage-categories.mdx).
|
||||
Reference in New Issue
Block a user