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:
Riqwan Thamir
2023-01-27 15:25:46 +01:00
committed by GitHub
co-authored by Philip Korsholm
parent 44dbe55f50
commit ee42b60a20
12 changed files with 249 additions and 6 deletions
@@ -56,11 +56,11 @@ export class ProductCategory extends SoftDeletableEntity {
@JoinTable({
name: "product_category_product",
joinColumn: {
name: "product_id",
name: "product_category_id",
referencedColumnName: "id",
},
inverseJoinColumn: {
name: "product_category_id",
name: "product_id",
referencedColumnName: "id",
},
})
@@ -122,6 +122,12 @@ export class ProductCategory extends SoftDeletableEntity {
* parent_category:
* description: A product category object. Available if the relation `parent_category` is expanded.
* type: object
* products:
* description: products associated with category. Available if the relation `products` is expanded.
* type: array
* items:
* type: object
* description: A product object.
* created_at:
* type: string
* description: "The date with timezone at which the resource was created."
+8 -2
View File
@@ -82,11 +82,11 @@ export class Product extends SoftDeletableEntity {
@JoinTable({
name: "product_category_product",
joinColumn: {
name: "product_category_id",
name: "product_id",
referencedColumnName: "id",
},
inverseJoinColumn: {
name: "product_id",
name: "product_category_id",
referencedColumnName: "id",
},
})
@@ -320,6 +320,12 @@ export class Product extends SoftDeletableEntity {
* items:
* type: object
* description: A sales channel object.
* categories:
* description: The product's associated categories. Available if the relation `categories` is expanded.
* type: array
* items:
* type: object
* description: A category object.
* created_at:
* type: string
* description: "The date with timezone at which the resource was created."