Skip to content

Conversation

upchuk
Copy link

@upchuk upchuk commented Dec 9, 2018

Since it's not really possible in Drupal to nicely prevent entity deletions at API level, a good first start is to prevent users from even accidentally deleting attribute values that are in used by product variation types.

So in this PR, I basically make the necessary query to determine if the attribute value is in use or not.

This is a POC, untested, and can potentially be improved. For example, here I only prevent the Delete button but we can also argue the value itself (or the entire row) to be disabled. I am not sure. Or we could use database queries instead of the entity API to determine in one single query the usage of ALL attribute values across all variation type. Might be more performant.

Please let me know if this approach is ok and i will also provide functional tests.

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

Successfully merging this pull request may close these issues.

1 participant