medusa-admin-category
v0.0.6
Published
A Medusa plugin that adds category image upload functionality to the admin dashboard.
Maintainers
Readme
Medusa Admin Category Image Plugin
This plugin adds a category image upload widget to the Medusa admin dashboard and extends the product category data model.
Features
- ✅ Database Schema: Adds an
imagecolumn to theproduct_categorytable via migration. - ✅ API Extension: Overrides standard category Create/Update APIs to handle image uploads and removals.
- ✅ Admin UI: Adds image selection to the category create/edit modals and keeps a widget on the category details page to upload, view, replace, and remove images.
- ✅ Storage: Uses Medusa's built-in file upload API.
Installation
- Add the plugin to your Medusa project:
cd /path/to/your/medusa-project
yarn add file:/Users/pradipparmar/git/ecommerce/medusa-plugins/medusa-admin-category- Add the plugin to your
medusa-config.ts:
import { defineConfig } from "@medusajs/framework/utils"
export default defineConfig({
// ... other config
plugins: [
// ... other plugins
{
resolve: "medusa-admin-category",
},
],
})- Run Migrations:
Since this plugin adds a database column, you need to run migrations:
npx medusa db:migrate- Restart your Medusa server:
yarn devUsage
- Navigate to Settings → Product Categories.
- Click on a category to view its details.
- Use the Category Image widget at the bottom to upload or manage the image.
Technical Details
Database
- Migration:
1732186200000-add-product-category-image.ts - Column:
image(varchar) added toproduct_categorytable.
API Overrides
POST /admin/product-categories: Handles creation with image.POST /admin/product-categories/:id: Handles updates with image.- Logic: Stores image URL in
metadata.image_urlfor immediate availability and compatibility with the widget.
Widget
- Location:
product_category.details.after - Functionality: Uploads to
/admin/uploads, then updates category metadata.
License
MIT
