Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: CreateProductOptionDTO is missing metadata property #11424

Open
fogine opened this issue Feb 12, 2025 · 3 comments
Open

[Bug]: CreateProductOptionDTO is missing metadata property #11424

fogine opened this issue Feb 12, 2025 · 3 comments

Comments

@fogine
Copy link

fogine commented Feb 12, 2025

Package.json file

{
  "dependencies": {
    "@medusajs/admin-sdk": "2.4.0",
    "@medusajs/cli": "2.4.0",
    "@medusajs/framework": "2.4.0",
    "@medusajs/medusa": "2.4.0",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "awilix": "^8.0.1",
    "axios": "^1.7.9",
    "pg": "^8.13.0",
    "printify-sdk-js": "^1.3.0-beta.1",
    "rambda": "^9.4.1"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.1.3",
    "@mikro-orm/cli": "6.4.3",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v20

Database and its version

17.2

Operating system name and version

linux

Browser name

No response

What happended?

CreateProductWorkflowInputDTO does not allow to set metadata properties on product_option and product_option_value database entities. Likewise UpdateProductWorkflowInputDTO.

When creating product option with its values, I want to assign json metadata to the option. However CreateProductOptionDTO does not have metadata property.

As far as I know there is no way how to set additional data to product options when calling batchProductsWorkflow.

Expected behavior

When creating/importing a product, I want to be able to define additional metadata because value property for an option is not enough.
I need to define label for each option as well.
Also it should be possible to assign metadata for each option value, not just to the option entity itself:

{
    options: [
        {
            title: 'Color',
            values: [
                {value: '#ffffff', metadata: {additional: 'data'}  //not supported, currently accepts values:string[]
            ],
            metadata: {additional: 'data'} //not supported
    ]
}

Actual behavior

currently its only possible to set:

{
    options: [
        {
            title: 'Color',
            values: [
               'string-value'
            ],
    ]
}

Link to reproduction repo

not relevant

@riqwan
Copy link
Contributor

riqwan commented Feb 13, 2025

Thanks @fogine, would you like to try opening a PR for this?

@fogine
Copy link
Author

fogine commented Feb 13, 2025

I could. Is there a guide how can I setup the repository for development? @riqwan
I cloned medusa repo and installed dependencies with yarn but when I have for example file opened:
packages/medusa/src/api/store/products/route.ts. Typescript gives me errors that it cant find @medusajs/framework/utils and other modules..

@riqwan
Copy link
Contributor

riqwan commented Feb 13, 2025

Yes - https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md#workflow

In your case, you just have to do yarn && yarn build from root. With just this type change, you can go ahead and open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants