medusa-fashion-product-seeder
v0.1.4
Published
Reusable fashion-focused Medusa product seeder with generated products, variants, and images.
Maintainers
Readme
medusa-fashion-product-seeder
A reusable Medusa fashion catalog generator with both:
- a library API for custom seed scripts
- a CLI for seeding or clearing products from an installed node module
It generates a deterministic demo catalog with:
- 100 products by default
- 1-4 variants per product
- multiple images per product
- reusable fashion category definitions
- configurable image builder, brand name, count, and pricing
Install
Install it in your Medusa backend project:
pnpm add medusa-fashion-product-seederCLI
The package ships with a CLI that runs against a Medusa backend directory.
From inside your backend directory:
pnpm exec medusa-fashion-product-seeder seedFrom a monorepo root:
pnpm exec medusa-fashion-product-seeder seed --project-dir ./apps/backendAvailable commands:
pnpm exec medusa-fashion-product-seeder seed --project-dir ./apps/backend --count 100
pnpm exec medusa-fashion-product-seeder clear --project-dir ./apps/backend
pnpm exec medusa-fashion-product-seeder reset --project-dir ./apps/backend --count 100
pnpm exec medusa-fashion-product-seeder clear --project-dir ./apps/backend --all --confirmBehavior notes:
seedcreates fashion categories if they do not already exist.seeduses the handle prefixfashion-seederby default so the generated catalog is namespaced.cleardeletes only products created with that prefix unless you pass--all --confirm.clearuses Medusa's delete workflow, so products are removed from the active catalog using Medusa's normal deletion behavior.resetclears the prefixed catalog and seeds it again.- if your backend uses
medusa-config.ts, the CLI automatically registersts-nodefrom the target project before bootstrapping Medusa.
Useful options:
--project-dir <path>
--count <number>
--brand <name>
--handle-prefix <prefix>
--all
--confirmLibrary API
Use the library API when you want to keep full control inside your own Medusa seed script.
import {
DEFAULT_FASHION_CATEGORIES,
buildFashionCatalogProducts,
mapFashionCategoryIdsByName,
} from "medusa-fashion-product-seeder"
const { result: categories } = await createProductCategoriesWorkflow(container).run({
input: {
product_categories: DEFAULT_FASHION_CATEGORIES,
},
})
const categoryIdByName = mapFashionCategoryIdsByName(categories)
const products = buildFashionCatalogProducts({
count: 100,
brand: "North Studio",
shippingProfileId: shippingProfile.id,
salesChannelId: defaultSalesChannel.id,
categoryIdByName,
})
await createProductsWorkflow(container).run({
input: { products },
})Custom images
By default, the package uses placehold.co image URLs so the catalog works out of the box.
You can swap in your own CDN, Cloudinary, S3, or static asset pipeline:
const products = buildFashionCatalogProducts({
shippingProfileId,
salesChannelId,
categoryIdByName,
imageBuilder: ({ handle, themeLabel, productIndex }) => [
`https://cdn.example.com/products/${handle}/${themeLabel.toLowerCase()}-${productIndex}-1.jpg`,
`https://cdn.example.com/products/${handle}/${themeLabel.toLowerCase()}-${productIndex}-2.jpg`,
],
})