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

Issue #2815513 - Forbid deletion of attribute values that are in use #868

Open
wants to merge 1 commit into
base: 8.x-2.x
Choose a base branch
from

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