Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
upchuk wants to merge 1 commit intodrupalcommerce:8.x-2.x from
upchuk:2815513
Open

Issue #2815513 - Forbid deletion of attribute values that are in use #868
upchuk wants to merge 1 commit intodrupalcommerce:8.x-2.x from
upchuk:2815513

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

Comments

AltStyle によって変換されたページ (->オリジナル) /