Skip to content

Commit

Permalink
fix(medusa): fix bug with parent not being saved correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan committed Mar 20, 2023
1 parent 98cad6d commit 6f1c73d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-chefs-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix(medusa): fix bug with parent not being saved correctly
6 changes: 3 additions & 3 deletions packages/medusa/src/commands/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit 6f1c73d

Please sign in to comment.