Needs work
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Product
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2016 at 00:21 UTC
Updated:
12 Oct 2022 at 03:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jpdaut commentedComment #3
jpdaut commentedPerhaps that was not permitted, what I did, and I'm not using the data model correctly? It's really not clear to me right now. I was just reading this comment in https://www.drupal.org/node/2683605#comment-10946699: "Currently when creating a product type, you select the variation type to use for it. Once created, it is locked forever (or until deleted). If you need a new variation, you are forced to create a new product type to house that variation."
I'm also changing this to Support request as I'm not sure of my claim here.
Comment #4
bojanz commentedThe bug is that Commerce allowed you to delete an attribute that's in use.
Once an entity is referenced, it mustn't be deleted, because Drupal generally handles that poorly.
We don't have an API for preventing deletions yet.
Comment #5
czigor commentedUntil that happens, here's a patch that gives sites a chance to fix things after removing an attribute in use.
(Coming here from #2826006: Product variation referencing a missing product attribute value..)
Comment #6
pavelculacov commentedTested, worked, thanks
Comment #7
bojanz commentedWe need to forbid deletion in this case. We also need to make the add to cart form non-crashy, cause this will always be a possibility (if a custom reference field was used, for example).
Comment #8
bojanz commentedComment #9
drugan commentedEncountered this issue today again. Might be this at least temporarily fixed? ..before something will appear on the #2898215: [meta] Handle deletion of Commerce entities that are in use
Comment #10
upchuk commentedPull request with POC in Github: https://github.com/drupalcommerce/commerce/pull/868
Comment #13
bojanz commentedWe need to decide what the UX is going to be. The exploration in #10 disables the Remove button, but that doesn't tell the user why the button is disabled, or how to resolve it. One option would be to show a message as a validation error when the Remove button is clicked. The other option would be to show a message instead of the Remove button (probably a different, shorter message than the validation error one).
We need to brainstorm both versions of the message.
I'll raise this with others on the team.
Comment #14
tonytheferg commentednevermind.
Comment #15
bamberjp commentedBuilding on the above idea, patch included (#15) adds a conditionGroup to query a count of product variations referencing the attribute value and caches the result for performance.