product-relations-plugin

1.4.8 • Public • Published

Medusa Services & Assets

Overview

The Product Relations Plugin for Medusa extends your e-commerce capabilities by adding dedicated entities to manage customer purchases and services more effectively. This plugin introduces two key concepts:

  • Assets: Track physical products with unique identifiers (like serial numbers) that customers have purchased
  • Service Instances: Manage services that can be either attached to assets (like extended warranties, maintenance plans) or exist independently (such as rentals, repairs, or standalone services)

Additionally, this plugin enhances product variants by allowing you to create references to other products, such as spare parts or replacements, making it easier to manage product relationships and accessories.

When plugin is installed, new menu options should appear in backoffice. There are dedicated pages to manage Service instances and Assets with ability to create, modify and delete them.

You can find admin API definition in repo files.

Compatibility

This starter is compatible with versions >= 2.4.0 of @medusajs/medusa.

Installation

  1. Install plugin by adding to your package.json:
...
"product-relations-plugin": "^1.4.7"/ // or other available version
...
  1. Execute install (yarn install)

  2. Add plugin to uour medusa-config.js:

...
plugins: [
  {
    resolve: "product-relations-plugin",
    options: {}
  }
]
...
  1. This plugin introduces new models in database so you need to execute migration:
npx medusa db:migrate

Known issues

  1. Can't set empty list of assets on service instance. Unlinking item by item works but last one stays for unknown reason.

Models schema

Services & Assets

---
  config:
    class:
      hideEmptyMembersBox: true
---
classDiagram
    ServiceInstance --> PaymenntTypeEnum : has
    ServiceInstance --> ServiceItemStatusEnum : has

    ServiceInstance "0..*" <--> "0..*" Asset

    ServiceInstance "1" --> "1" ProductVariant

    Asset "1" --> "1" Address

    Asset "1" --> "1" Customer

    ServiceInstance "1" --> "1" Customer

    Asset "1" --> "1" ProductVariant

    ProductVariant "1" --> "0..*" ProductReference

    ProductReference --> ProductVariant_

    class ServiceInstance{
        String name
        Date startDate
        Date endDate
        Date purchaseDate
        Price price
    }

    class PaymenntTypeEnum{
        ONE_TIME
        WEEKLY
        MONTHLY
        YEARLY
    }

    class ServiceItemStatusEnum{
        ACTIVE
        INACTIVE
        RETIRED
    }

    class Asset{
        String name
        String serialNumber
        String thumbnail
        Date endOfWarranty
    }

    class Address{
    }

    class ProductVariant{

    }

    class Customer{

    }

    class ProductReference{
        SPARE_PART
        COMPATIBLE_SERVICE
    }

Package Sidebar

Install

npm i product-relations-plugin

Weekly Downloads

9

Version

1.4.8

License

MIT

Unpacked Size

572 kB

Total Files

37

Last publish

Collaborators

  • shriz07