From 7f2223b6507b0a3c452977bfcdee92af2086fa29 Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Tue, 21 Mar 2023 09:37:13 +0100 Subject: [PATCH] fix(medusa): fix bug with parent not being saved correctly (#3534) What: - Parent was being updated incorrectly because of a weird typeorm issue, making the rank pick up the wrong entity's rank. This PR fixes that issue by passing in an ID and letting the service take care of fetching the parent. RESOLVES CORE-1274 --- .changeset/stupid-chefs-ring.md | 5 +++++ packages/medusa/src/commands/seed.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/stupid-chefs-ring.md diff --git a/.changeset/stupid-chefs-ring.md b/.changeset/stupid-chefs-ring.md new file mode 100644 index 0000000000..722cffba52 --- /dev/null +++ b/.changeset/stupid-chefs-ring.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): fix bug with parent not being saved correctly diff --git a/packages/medusa/src/commands/seed.ts b/packages/medusa/src/commands/seed.ts index 47fd815394..1d40603e08 100644 --- a/packages/medusa/src/commands/seed.ts +++ b/packages/medusa/src/commands/seed.ts @@ -213,12 +213,12 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) { const createProductCategory = async ( parameters, - parentCategory: ProductCategory | null = null + parentCategoryId: string | null = null ) => { // default to the categories being visible and public parameters.is_active = parameters.is_active || true parameters.is_internal = parameters.is_internal || false - parameters.parent_category = parentCategory || null + parameters.parent_category_id = parentCategoryId const categoryChildren = parameters.category_children || [] delete parameters.category_children @@ -229,7 +229,7 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) { if (categoryChildren.length) { for (const categoryChild of categoryChildren) { - await createProductCategory(categoryChild, category) + await createProductCategory(categoryChild, category.id) } } }