Came accross to this when exporting product data from external system and wanted temporarily inactivate the product variation as exported data had faulty price in it.
To reproduce: create a product entity with status active, assign a single product variation to it, uncheck Active checkbox to set variation as inactive, update variation and then save product entity.
If you now try to open the detail page of the product entity, you'll get this error:
Recoverable fatal error: Argument 1 passed to Drupal\commerce_order\OrderItemStorage::createFromPurchasableEntity() must implement interface Drupal\commerce\PurchasableEntityInterface, null given, called in /var/www/drupalvm/drupal/web/modules/contrib/commerce/modules/product/src/ProductLazyBuilders.php on line 59 and defined in Drupal\commerce_order\OrderItemStorage->createFromPurchasableEntity() (line 16 of modules/contrib/commerce/modules/order/src/OrderItemStorage.php).
Comment | File | Size | Author |
---|---|---|---|
#2 | product_entities-2852273-2.patch | 1.25 KB | mitrpaka |
Comments
Comment #2
mitrpaka CreditAttribution: mitrpaka as a volunteer commentedComment #3
mitrpaka CreditAttribution: mitrpaka as a volunteer commentedComment #4
bojanz CreditAttribution: bojanz at Centarro commentedWe also need to document that getDefaultVariation() can be NULL.
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedTweaked and committed, thanks!
Comment #7
niko- CreditAttribution: niko- as a volunteer commentedIn this case better solution will show product page with disabled add to cart button
Comment #8
niko- CreditAttribution: niko- as a volunteer commentedI propose select first variation and show product page with disabled or hidden $form['actions'] here
Comment #9
vasikei think this issue is fixed (closed).
@niko- imho, it think it's best to open new issue(s) about add to cart and no default variation.
thanks
Comment #10
bojanz CreditAttribution: bojanz at Centarro commentedIf there's no default variation, that means that there are no active variations at all. So it's not possible to do #7 / #8.