Deleted attributes, now encountering error when trying to access product variation type

Created on 24 July 2019, over 5 years ago
Updated 10 April 2023, almost 2 years ago

Hello,

I am learning the product attribute/variation system and came across an issue today. I created two "Test" attributes and enabled them on my Product Variation. I then created a test product and added variations based on those attributes.

My testing complete, I deleted the two "Test" attributes. Now, I am unable to access the edit screen of my product variation that had those attributes enabled. I have tried clearing cache, but that did not fix the issue.

The on-screen error is: "The website encountered an unexpected error. Please try again later."

The log error message is:

TypeError: Argument 1 passed to Drupal\commerce_product\ProductAttributeFieldManager::canDeleteField() must implement interface Drupal\commerce_product\Entity\ProductAttributeInterface, null given, called in /home/mysite/public_html/modules/commerce/modules/product/src/Form/ProductVariationTypeForm.php on line 127 in Drupal\commerce_product\ProductAttributeFieldManager->canDeleteField() (line 216 of /home/mysite/public_html/modules/commerce/modules/product/src/ProductAttributeFieldManager.php) #0 /home/mysite/public_html/modules/commerce/modules/product/src/Form/ProductVariationTypeForm.php(127): Drupal\commerce_product\ProductAttributeFieldManager->canDeleteField(NULL, 'shippable_produ...') #1 /home/mysite/public_html/core/lib/Drupal/Core/Entity/EntityForm.php(117): Drupal\commerce_product\Form\ProductVariationTypeForm->form(Array, Object(Drupal\Core\Form\FormState)) #2 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #3 /home/mysite/public_html/core/lib/Drupal/Core/Form/FormBuilder.php(519): call_user_func_array(Array, Array) #4 /home/mysite/public_html/core/lib/Drupal/Core/Form/FormBuilder.php(276): Drupal\Core\Form\FormBuilder->retrieveForm('commerce_produc...', Object(Drupal\Core\Form\FormState)) #5 /home/mysite/public_html/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('commerce_produc...', Object(Drupal\Core\Form\FormState)) #6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #7 /home/mysite/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #8 /home/mysite/public_html/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #9 /home/mysite/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #10 /home/mysite/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #11 /home/mysite/public_html/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #12 /home/mysite/public_html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #13 /home/mysite/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /home/mysite/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /home/mysite/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /home/mysite/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /home/mysite/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /home/mysite/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /home/mysite/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /home/mysite/public_html/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /home/mysite/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #22 {main}.

I'm sure i shouldn't have deleted the attribute the way that I did, but this seems like something that could be screwed up really easy, causing a website to partially crash like this. I do have a database backup, but I wanted to see if anyone could tell me how to fix the issue instead.

πŸ› Bug report
Status

Closed: duplicate

Version

2.13

Component

Price

Created by

πŸ‡ΊπŸ‡ΈUnited States hockey2112

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States sleewok

    I'm somewhat shocked that this has not been dealt with. This is not some complicated task that a user would have to jump through loops to trigger. It completely breaks the "edit product variation" functionality until you manually delete the field from the variation.

Production build 0.71.5 2024