medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.31k stars 2.38k forks source link

Cannot delete product option when there are at least 2 options and variants #5166

Open milan-zami-tech opened 11 months ago

milan-zami-tech commented 11 months ago

Bug report

When the product contains at least 2 options and 2 variants and we try to delete the option in the admin dashboard, it will show a successful message, but the option will not be deleted. Also if we try to delete the option with admin API, then we get the following:

{
    "type": "invalid_data",
    "message": "To delete an option, first delete all variants, such that when an option is deleted, no duplicate variants will exist."
}

System information

Medusa version (including plugins): "@medusajs/admin": "^7.0.1", "@medusajs/cache-inmemory": "^1.8.8", "@medusajs/cache-redis": "^1.8.8", "@medusajs/event-bus-local": "^1.9.6", "@medusajs/event-bus-redis": "^1.8.9", "@medusajs/file-local": "^1.0.2", "@medusajs/icons": "^1.0.0", "@medusajs/medusa": "^1.15.0", "@medusajs/ui": "^1.0.0", "@tanstack/react-query": "4.22.0", "babel-preset-medusa-package": "^1.1.13", "body-parser": "^1.19.0", "cors": "^2.8.5", "dotenv": "16.0.3", "express": "^4.17.2", "medusa-fulfillment-manual": "^1.1.38", "medusa-interfaces": "^1.3.7", "medusa-payment-manual": "^1.0.24", "medusa-payment-stripe": "^6.0.3", "prism-react-renderer": "^2.0.4", "typeorm": "^0.3.16"

Node.js version: 16.20.1 Database: PostgreSQL 14.9 Operating system: Pop!_OS 22.04 LTS

Steps to reproduce the behavior

Naming doesn't matter.

  1. Create product Test (draft or published)
  2. Variants > Edit Options > Add two options: A, B
  3. Variants > Add Variant > A: 1, B: 2
  4. Repeat step 3 with values A: 3, B: 4
  5. Variants > Edit Options > delete option B
  6. We get a message that the action was successful, but the option is not deleted

Expected behavior

Option B should be deleted

lemon-sandwich commented 10 months ago

I'm dealing with the same issue.

olivermrbl commented 9 months ago

@milan-zami-tech @lemon-sandwich, and following the instructions in the error message did not work? It is unclear from your message, if you tried that.

milan-zami-tech commented 9 months ago

My understanding of that error message is if we have options(A, B) and next variants: Variant 1: A = 1, B = 1 Variant 2: A = 1, B = 2 When we try to delete option B, it prevents us from deleting it so we don't have two variants with the same option values as in this example.

This is not the case with my variants, which have different values for option A.

VENGENCE7 commented 4 months ago

Was Facing the same issue here

I had a product with 3 options and 2 variants

BUG FOUND : it shows success notification but in response of the api we receive the below message. MEDUSA guys please have a look here

{ "type": "invalid_data", "message": "To delete an option, first delete all variants, such that when an option is deleted, no duplicate variants will exist." }

Current Solution : Delete the variants and you should now be able to delete the options (just as the response says)

For Medusa :