feat: Revamp of product categories (#7695)

* feat: Normalize the categories interface to match standards

* feat: Revamp the product category implementation

* fix: Adjustments to code and tests around product categories
This commit is contained in:
Stevche Radevski
2024-06-13 09:10:12 +02:00
committed by GitHub
parent fbd8eef18b
commit d862d03de0
35 changed files with 1135 additions and 874 deletions

View File

@@ -73,7 +73,7 @@ class ProductCategory {
nullable: false,
default: 0,
})
rank?: number
rank: number
@ManyToOne(() => ProductCategory, {
columnType: "text",
@@ -130,22 +130,7 @@ class ProductCategory {
this.handle = kebabCase(this.name)
}
const { em } = args
let parentCategory: ProductCategory | null = null
if (this.parent_category_id) {
parentCategory = await em.findOne(
ProductCategory,
this.parent_category_id
)
}
if (parentCategory) {
this.mpath = `${parentCategory?.mpath}${this.id}.`
} else {
this.mpath = `${this.id}.`
}
this.mpath = `${this.mpath ? this.mpath + "." : ""}${this.id}`
}
}