feat(medusa): Include Product Collections in Seed command (#5510)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(medusa): Include Product Collections in Seed command
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { DataSource, DataSourceOptions } from "typeorm"
|
import { DataSource, DataSourceOptions } from "typeorm"
|
||||||
import {
|
import {
|
||||||
ProductCategoryService,
|
ProductCategoryService,
|
||||||
|
ProductCollectionService,
|
||||||
ProductService,
|
ProductService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
RegionService,
|
RegionService,
|
||||||
@@ -11,7 +12,6 @@ import {
|
|||||||
UserService,
|
UserService,
|
||||||
} from "../services"
|
} from "../services"
|
||||||
import getMigrations, { getModuleSharedResources } from "./utils/get-migrations"
|
import getMigrations, { getModuleSharedResources } from "./utils/get-migrations"
|
||||||
|
|
||||||
import { IPricingModuleService } from "@medusajs/types"
|
import { IPricingModuleService } from "@medusajs/types"
|
||||||
import express from "express"
|
import express from "express"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
@@ -101,6 +101,9 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) {
|
|||||||
const storeService: StoreService = container.resolve("storeService")
|
const storeService: StoreService = container.resolve("storeService")
|
||||||
const userService: UserService = container.resolve("userService")
|
const userService: UserService = container.resolve("userService")
|
||||||
const regionService: RegionService = container.resolve("regionService")
|
const regionService: RegionService = container.resolve("regionService")
|
||||||
|
const productCollectionService: ProductCollectionService = container.resolve(
|
||||||
|
"productCollectionService"
|
||||||
|
)
|
||||||
const productService: ProductService = container.resolve("productService")
|
const productService: ProductService = container.resolve("productService")
|
||||||
const productCategoryService: ProductCategoryService = container.resolve(
|
const productCategoryService: ProductCategoryService = container.resolve(
|
||||||
"productCategoryService"
|
"productCategoryService"
|
||||||
@@ -131,6 +134,7 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) {
|
|||||||
const {
|
const {
|
||||||
store: seededStore,
|
store: seededStore,
|
||||||
regions,
|
regions,
|
||||||
|
product_collections = [],
|
||||||
products,
|
products,
|
||||||
categories = [],
|
categories = [],
|
||||||
shipping_options,
|
shipping_options,
|
||||||
@@ -212,6 +216,10 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) {
|
|||||||
await createProductCategory(c)
|
await createProductCategory(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const pc of product_collections) {
|
||||||
|
await productCollectionService.withTransaction(tx).create(pc)
|
||||||
|
}
|
||||||
|
|
||||||
for (const p of products) {
|
for (const p of products) {
|
||||||
const variants = p.variants
|
const variants = p.variants
|
||||||
delete p.variants
|
delete p.variants
|
||||||
|
|||||||
Reference in New Issue
Block a user