Skip to content

Latest commit

 

History

138 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@nicogorga/medusa-product-attributes

Create global (category specific) product attributes on your Medusa commerce application

Warning

This plugin is a WIP and I am working on it in my spare time between projects and work. Feel free to make contributions by making pull requests and proposing ideas / new flows to implement via Discussions If this helps you, you can buy me a ☕ or reach out to me if you need help with your MedusaJS projects 😉

Compatibility

This plugin is compatible with versions >= 2.6.1 of @medusajs/medusa.

Progress

All the progress is recorded in CHANGELOG.md and so far, it is solely focused on backend (you can use the functionallities via API calls)

Roadmap

  • Create Admin panel widgets link attribute values to products

Prerequisites

How to Install

1. Run the following command in the directory of the Medusa backend using your package manager (for example for npm):

npm install @nicogorga/medusa-product-attributes

2. In medusa-config.ts add the following to the plugins array in your project config:

  module.exports = defineConfig({
    projectConfig: {
      // ...
    },
    plugins: [
      {
        resolve: `@nicogorga/medusa-product-attributes`,
        options: {}
      }
    ]
  })

3. In your already existent or new createProductsWorkflow.productsCreated hook handler, import productsCreatedHookHandler and call it like following. This is important as it's what links new products to the requested attribute values (if any):

import { createProductsWorkflow } from "@medusajs/medusa/core-flows";
import { productsCreatedHookHandler } from "@nicogorga/medusa-product-attributes/utils/products-created-handler"

createProductsWorkflow.hooks.productsCreated(
    async ({ products, additional_data }, { container }) => {
      const links = await productsCreatedHookHandler({ products, additional_data, container })

      // Your own logic (if any). You can return 'links' to your compensation function, to dismiss the links if an error occurs
    }
)

4. In your already existent or new updateProductsWorkflow.productsUpdated hook handler, import productUpdatedHookHandler and call it like following. This is important as it's what updated the porduct attributes, with the requested attribute values (if any):

import { updateProductsWorkflow } from "@medusajs/medusa/core-flows";
import { productsUpdatedHookHandler } from "@nicogorga/medusa-product-attributes/utils/products-updated-handler"

updateProductsWorkflow.hooks.productsUpdated(
    async ({ products, additional_data }, { container }) => {
      const links = await productsUpdatedHookHandler({ products, additional_data, container })

      // Your own logic (if any). You can return 'links' to your compensation function, to dismiss the links if an error occurs
    }
)

Additional Resources

About

Medusa Plugin to introduce Global or Category level common product attributes, to facilitate filtering and Variant definition

Resources

Stars

28 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages