Missing bundle for entity type commerce_order_item

Created on 22 August 2018, over 6 years ago
Updated 29 December 2024, 4 months ago

Attached shows config format display. This issue doesn't occur until switching from rendered entity to add to cart as shown in attached.

On product page load under footer comes error: Missing bundle for entity type commerce_order_item

dblog shows:
Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type commerce_order_item in Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 75 of /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php) #0 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(184): Drupal\Core\Entity\ContentEntityStorageBase->doCreate(Array) #1 /app/web/modules/contrib/commerce/modules/order/src/OrderItemStorage.php(23): Drupal\Core\Entity\EntityStorageBase->create(Array) #2 /app/web/modules/contrib/commerce/modules/product/src/ProductLazyBuilders.php(80): Drupal\commerce_order\OrderItemStorage->createFromPurchasableEntity(Object(Drupal\commerce_product\Entity\ProductVariation)) #3 [internal function]: Drupal\commerce_product\ProductLazyBuilders->addToCartForm('15', 'full', true, 'en') #4 /app/web/core/lib/Drupal/Core/Render/Renderer.php(358): call_user_func_array(Array, Array) #5 /app/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true) #6 /app/web/core/lib/Drupal/Core/Render/Renderer.php(151): Drupal\Core\Render\Renderer->render(Array, true) #7 /app/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #8 /app/web/core/lib/Drupal/Core/Render/Renderer.php(152): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #9 /app/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->renderPlain(Array) #10 /app/web/core/modules/big_pipe/src/Render/BigPipe.php(696): Drupal\Core\Render\Renderer->renderPlaceholder('callback=commer...', Array) #11 /app/web/core/modules/big_pipe/src/Render/BigPipe.php(550): Drupal\big_pipe\Render\BigPipe->renderPlaceholder('callback=commer...', Array) #12 /app/web/core/modules/big_pipe/src/Render/BigPipe.php(305): Drupal\big_pipe\Render\BigPipe->sendPlaceholders(Array, Array, Object(Drupal\Core\Asset\AttachedAssets)) #13 /app/web/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe\Render\BigPipe->sendContent(Object(Drupal\big_pipe\Render\BigPipeResponse)) #14 /app/vendor/symfony/http-foundation/Response.php(373): Drupal\big_pipe\Render\BigPipeResponse->sendContent() #15 /app/web/index.php(20): Symfony\Component\HttpFoundation\Response->send() #16 {main}.

I've tried various config with keeping add to cart in manage display for the entity reference field, Variations, though same error remained. I also looked to debug line 72 but all I could tell was that $this->bundleKey had value of type, and that $values[$this->bundleKey] is null.

var_dump shows from ContentEntityStorageBase.php that the array begins with: 'type' => NULL 'title' => string(4) "EZ12"

Not sure what step to take next on it.

🐛 Bug report
Status

Needs review

Version

2.8

Component

Product

Created by

🇺🇸United States vrwired Colorado

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.

  • 🇦🇺Australia 2pha

    I just got this error while playing with D11.1 and commerce 3.0.0-beta2.
    I get this error when viewing the product page as an anonymous user, weirdly I do not get the error when logged in, but I do not see the add to cart button.
    As in the image attached to the issue, Changing the variations field on the product display to something other than "add to cart form" does get rid of the error. But ofcourse, you get no add to cart button..

    My set up is a new install of Drupal 11.1 with only drupal commerce installed.
    I have 1 product type (other than default) which uses a single custom variation type (other than default).

  • 🇮🇱Israel jsacksick

    I had to edit the Product Variation Type and set "Order Item Type". As I had installed the Order module after creating the product variation, it was not set.

    Yes, this is precisely what the patch is fixing, but I'm not sure we can safely assume that the order item type should be set to "default" for custom variation types.
    The problem is if it doesn't break anymore, it is easy to miss this extra configuration step.

Production build 0.71.5 2024