Editing a product becomes impossible after deleting a product attribute

Created on 22 July 2025, 10 days ago

Describe your bug or feature request.

First I went through a nightmare of a time trying to uninstall commerce_license (which caused all the same errors this is causing) when deleting a commerce product attribute (that wasn't even used anywhere) and you have one hell of a nightmare on your hands. Because even tho on delete of the product attribute you receive a message saying the field it created and its config will also be deleted when in fact it actually is not deleted or configs removed.
Furthermore exporting the affected configs and removing the reference to the product attribute won't import because of every other related connection between configs entities and fields won't allow it, for example:

The configuration cannot be imported because it failed validation for the following reasons:
Configuration core.entity_form_display.commerce_product_variation.default_postit_product_var.default depends on configuration (commerce_product.commerce_product_variation_type.default_postit_product_var, field.field.commerce_product_variation.default_postit_product_var.license_expiration, field.field.commerce_product_variation.default_postit_product_var.license_type) that will not exist after import.
Configuration core.entity_view_display.commerce_product_variation.default_postit_product_var.default depends on configuration (commerce_product.commerce_product_variation_type.default_postit_product_var, field.field.commerce_product_variation.default_postit_product_var.license_expiration, field.field.commerce_product_variation.default_postit_product_var.license_type) that will not exist after import.
Configuration field.field.commerce_product_variation.default_postit_product_var.attribute_options_prod_attr depends on the commerce_product.commerce_product_variation_type.default_postit_product_var configuration that will not exist after import.
Configuration field.field.commerce_product_variation.default_postit_product_var.billing_schedule depends on the commerce_product.commerce_product_variation_type.default_postit_product_var configuration that will not exist after import.
Configuration field.field.commerce_product_variation.default_postit_product_var.field_prod_var_media depends on the commerce_product.commerce_product_variation_type.default_postit_product_var configuration that will not exist after import.
Configuration field.field.commerce_product_variation.default_postit_product_var.subscription_type depends on the commerce_product.commerce_product_variation_type.default_postit_product_var configuration that will not exist after import.
Configuration language.content_settings.commerce_product_variation.default_postit_product_var depends on the commerce_product.commerce_product_variation_type.default_postit_product_var configuration that will not exist after import.

Using drush cdel and config name only gets you so far. After deleting the initial config reported in the error it only allowed for the product attributes/variations to be updated again on products - no-longer showing the field related to the deleted product attribute. Which great at least I can make changes to them again however the field is still reported as an error on the status page:

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Product variation
The commerce_product_variation.attribute_combo_account_types field needs to be uninstalled.

- note the field name, because this is what drush reports:

----------------------------- ---------- ------------------------------------------------- ------------- 
  Field name                    Required   Field type                                        Cardinality  
 ----------------------------- ---------- ------------------------------------------------- ------------- 
  attribute_account_types       βœ”          entity_reference                                  1            
  attribute_options_prod_attr   βœ”          entity_reference                                  1            
  billing_schedule                         entity_reference                                  1            
  subscription_type                        commerce_plugin_item:commerce_subscription_type   1            
 ----------------------------- ---------- ------------------------------------------------- -------------

when using drush field:info commerce_product_variation posting there is no attribute_combo_account_types field it is gone, yet the error remains. This is exactly like the situation I had previously when trying to uninstall another module related to commerce the commerce_license module (which looking at the import error above there is still remaining commerce license configs on top of this which has just gotten out of hand in regards to how frustrating this is.

If there was an alternative to commerce with Drupal 10 or 11 I would happily switch but there is not.

If a bug, provide steps to reproduce it from a clean install.

In commerce config:
1. Under Store (set basic currency, store type, and create the store.

2. create an order type ( I created one called posting) with workflow default, generate a sequential number when order is placed, number patter set to the default one previously created (which means you may have to create that first..), Fill in basic info Shopping cart setting set as Shopping cart view form as Cart form, shopping cart block view as Cart block. Checkout flow left on Default.

3. Next create an order item type ( I again used posting) under Order type choose posting (the order type you just created) and I set taxable type to Digital goods.

4. Now create some product attributes, I created 2 originally (Account Types and Billing and Payment Options) they are select lists then I made the mistake of creating another called Combo Account Types( also a select list) thinking it should be separate from Account types (DO NOT CREATE THAT YET, i did it after create products later), later realized that was not the way to do what I needed - all I needed to do was add the additional options to the already existing Account Types product attribute - but I will provide more info on that later.

5. Next create a Product variation type (again I set as posting) and have generate variation titles based on attribute values checked, Traits allow subscriptions checked, Order item type set to previously created posting, Attributes set to Account Type, and Billing and Payment Options.

6. Now create a Product type (again i used posting), under variations where it says Product variation types Posting is checked along with Allow each product to have multiple variation and inject product variation fields into the rendered product.

7. Now back to commerce inbox go to products and create a product. I have three but one should suffice - My first product is titled "Sell It" and some information was provided, hit save and add variations. In variations for the product add some variations, setting required fields (price and the 2 product attributes previously created - select something from each list and save.)

8. Go back to config Product attributes and create another product attribute which for me was Combo Account Types as a select list creating a field with machine name attribute_combo_account_types (which originally my thought was using this on a different product) but when I realized (before actually using it as it was never set on any product as an attribute) this isn't what I wanted to do because all products originate from posting order type and posting variation types I should have just added the values to the original Account types attribute because when I went to create my third product which was a combination of the first two products I created and say that all 3 attributes where still required (meaning no way to just set the new attribute and leave Account types attribute empty because everything is required. So I didn't even finish creating the third product after hitting save and add attributes and deleted what had been started so the third product didn't exist yet.

9. So I went back to config and selected delete on attribute combo account types - I got a warning saying the field and config would be deleted and clicked OK and the field was deleted (at least it looked that way because the atrtibute was nolonger listed in product attributes), even ran drush cr for good measure after clearing all caches...

10. I then added to the Account types product attribute the select options I set in combo account types and then I went back to Products and tried to add my 3rd product again, got thru save and add variations again but then there it was the field was still there (even after dblog has a confirmed delete log) when trying to add a variation - accept now the select list was empty and now even just setting the other two attributes prevents the product from being saved.

11. Checked the other two products I created (maybe 1 for you) and upon going to variation and trying to edit or add a new one there it was the supposedly deleted combo account types field (empty) no selectable options and prevents the form from saving.

Which seems to be a huge problem with commerce in general (with that said I have a hard time believing commerce can be used reliably in live production site without all kinds of problems) sure lots of sites report using it but is anyone actually able to use it on a live production site and process orders and payments - and can they still after trying/testing something and then removing it? Anyone...?

I ended up having to use drush cdel to actually delete the field and it's config so it no longer appears on existing or new products when creating or editing a product (similar to the only know workarounds at getting commerce_license to uninstall) - however it has left problematic garbage everywhere. Exactly the same way commerce_license did/does (and I'll probably find out down the line other commerce core modules and contributed modules that work with commerce all have these same issues.

I wouldn't even know where to begin to debug this any further than I already have, and at this point it doesn't even look like uninstalling commerce without being left with a complete nightmare is an option leaving me in a real bad spot without forcibly removing modules and attempting to clean all the garbage left behind out of the database directly.

How can this effectively be fixed? Is there a way to completely remove all of commerce and it's related modules fields and configs so everything can be reinstalled without errors! I fear no being the problem will probably occur again should I decide something isn't needed. Which makes general use and working with commerce for anyone short of a developer almost impossible - anytime you want to remove something, something else breaks which makes it very difficult to try things out or test ideas without literally re-creating everything!

It's worth noting prior to this orders have been processed successfully via test api and payment gateways like stripe and paypal on the original 2 products I had created initially. Which all had to deleted, all of data along with the original products, attributes, variations, fields and other configs when I uninstalled commerce_license which was only added and configured but never used as the specific use case was deemed unneeded causing a very very similar (almost identical if not identical issue to this one) where upon an attempt to create a new product when adding variations the license module turned into a required setting which wasn't needed because the use it was intended for inevitably was not needed. This extended explanation only to show this continued recurring problem with commerce.

Commerce subscription is active as well with the installation and "was working" just fine via test payment gateway api's, hopefully it still is. That was all before commerce_license removal (which again was configured but never used, similar to the product attribute "created but not used") again having had to delete all products, variations, attributes and orders from commerce just to get back to this to only have it happen again - talk about beating your head off a brick wall!

For good measure:
I'm using Drupal version 10.5.1, PHP 8.3.15 and MySQL 8.4.3

πŸ› Bug report
Status

Active

Version

3.1

Component

Product

Created by

πŸ‡ΊπŸ‡ΈUnited States sidgrafix

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sidgrafix
  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    Adding this note:
    To get the error off the status page the Devel Entity Updates module is required (similar to the last step needed when uninstalling the commerce_license module).

    If the devel_entity_update module is installed using drush entup will list the commerce_product_variation entity type with a pending update saying The commerce_product_variation.attribute_combo_account_types field needs to be uninstalled. Followed by Do you wish to run all pending update? (yes/no) [yes]:
    - typing yes and enter followed by drush cr when it completes will remove the error from displaying on the status page (again same as commerce_license) but if you export the commerce_product_variation.posting.default config under its dependencies: config: - field.field.commerce_product_variation.posting.attribute_combo_account_types is still listed (leftover garbage, same as commerce_license) and it cannot be removed from the config in export and imported (same as commerce_license) which exposes all the garbage left over. Only option is to go as far as literally deleting all your products, product attributes and anything else related and recreate them all...again!

Production build 0.71.5 2024