Skip to content

Latest commit

 

History

History
93 lines (63 loc) · 2.31 KB

File metadata and controls

93 lines (63 loc) · 2.31 KB

Medusa v2 Example: Category Images

This directory holds the code for the Category Images Tutorial.

You can either:

Prerequisites

Installation

  1. Clone the repository and change to the category-images directory:
git clone https://github.com/medusajs/examples.git
cd examples/category-images

2. Rename the .env.template file to .env.

3. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.

4. Install dependencies:

yarn # or npm install

5. Setup and seed the database:

npx medusa db:setup
yarn seed # or npm run seed

6. Start the Medusa application:

yarn dev # or npm run dev

You can manage a product category's images from the Medusa Admin dashboard by going to a category's page.

Refer to the More Resources for OpenAPI Specs of custom API routes.

Copy into Existing Medusa Application

If you have an existing Medusa application, copy the following directories and files into your project:

  • src/admin
  • src/api/admin
  • src/api/middlewares.ts
  • src/links/product-category-image.ts
  • src/modules/product-media
  • src/workflows

Then, add the Product Media Module to medusa-config.ts:

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "./src/modules/product-media",
    }
  ],
})

After that, run migrations to create the necessary tables:

npx medusa db:migrate

Finally, start the Medusa application:

yarn dev # or npm run dev

You can manage a product category's images from the Medusa Admin dashboard by going to a category's page.

More Resources