feat(medusa): add or remove categories from products (#3114)
* wip * chore: fix issues with join table * chore: fix issues * chore: fix ordering issue on random failing test * chore: revert table name * chore: added oas for category * chore: update categories for a product * chore: add remove category test * chore: added changeset * chore: address review comments * Apply suggestions from code review Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
co-authored by
Philip Korsholm
parent
44dbe55f50
commit
ee42b60a20
@@ -65,6 +65,7 @@ describe("GET /admin/products/:id", () => {
|
||||
"tags",
|
||||
"type",
|
||||
"collection",
|
||||
"categories",
|
||||
"sales_channels",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from "../../../../services"
|
||||
import {
|
||||
ProductSalesChannelReq,
|
||||
ProductProductCategoryReq,
|
||||
ProductTagReq,
|
||||
ProductTypeReq,
|
||||
} from "../../../../types/product"
|
||||
@@ -340,6 +341,16 @@ class ProductVariantReq {
|
||||
* id:
|
||||
* description: The ID of an existing Sales channel.
|
||||
* type: string
|
||||
* categories:
|
||||
* description: "Categories to add the Product to."
|
||||
* type: array
|
||||
* items:
|
||||
* required:
|
||||
* - id
|
||||
* properties:
|
||||
* id:
|
||||
* description: The ID of a Product Category.
|
||||
* type: string
|
||||
* options:
|
||||
* description: The Options that the Product should have. These define on which properties the Product's Product Variants will differ.
|
||||
* type: array
|
||||
@@ -527,6 +538,12 @@ export class AdminPostProductsReq {
|
||||
])
|
||||
sales_channels?: ProductSalesChannelReq[]
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => ProductProductCategoryReq)
|
||||
@ValidateNested({ each: true })
|
||||
@IsArray()
|
||||
categories?: ProductProductCategoryReq[]
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => ProductOptionReq)
|
||||
@ValidateNested({ each: true })
|
||||
|
||||
@@ -100,6 +100,7 @@ export const defaultAdminProductRelations = [
|
||||
"tags",
|
||||
"type",
|
||||
"collection",
|
||||
"categories",
|
||||
]
|
||||
|
||||
export const defaultAdminProductFields: (keyof Product)[] = [
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
ProductSalesChannelReq,
|
||||
ProductTagReq,
|
||||
ProductTypeReq,
|
||||
ProductProductCategoryReq,
|
||||
} from "../../../../types/product"
|
||||
|
||||
import { Type } from "class-transformer"
|
||||
@@ -278,6 +279,16 @@ class ProductVariantReq {
|
||||
* id:
|
||||
* description: The ID of an existing Sales channel.
|
||||
* type: string
|
||||
* categories:
|
||||
* description: "Categories to add the Product to."
|
||||
* type: array
|
||||
* items:
|
||||
* required:
|
||||
* - id
|
||||
* properties:
|
||||
* id:
|
||||
* description: The ID of a Product Category.
|
||||
* type: string
|
||||
* variants:
|
||||
* description: A list of Product Variants to create with the Product.
|
||||
* type: array
|
||||
@@ -459,6 +470,12 @@ export class AdminPostProductsProductReq {
|
||||
])
|
||||
sales_channels?: ProductSalesChannelReq[] | null
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => ProductProductCategoryReq)
|
||||
@ValidateNested({ each: true })
|
||||
@IsArray()
|
||||
categories?: ProductProductCategoryReq[]
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => ProductVariantReq)
|
||||
@ValidateNested({ each: true })
|
||||
|
||||
Reference in New Issue
Block a user