Each entity type that can be used as a line item source (such as commerce_product_variation) must be given a "cart" view mode.
We'll need to do this by implementing hook_rebuild() in the cart module.
Process:
1) Take the entity manager from \Drupal::service('entity.manager')
2) Find a list of relevant entity types:
$entityTypes = \Drupal::service('entity.manager')->getDefinitions();
$sourceEntityTypes = array_filter($entityTypes, function($entityType) {
return $entityType->isSubclassOf('\Drupal\commerce\LineItemSourceInterface');
});
3) For each entity type id, try to load the "cart" view mode, using EntityViewMode::load($entity_type . '.cart').
4) If missing, create it, using EntityViewMode::create() and then $entity->save().
If this works, you will be able to clear the caches, go to the "Manage display" tab of a product variation type, and see a Cart view mode.
Comment | File | Size | Author |
---|---|---|---|
#7 | cart-view-mode-2543390-7.patch | 1.81 KB | dbolinovski |
Comments
Comment #1
bojanz CreditAttribution: bojanz at Centarro commentedComment #2
joshtaylor CreditAttribution: joshtaylor commentedBlocked by #2543436: Configuration objects (views.view.commerce_cart_form) provided by commerce_cart have unmet dependencies.
Comment #3
joshtaylor CreditAttribution: joshtaylor at Josh Taylor Development commentedComment #4
joshtaylor CreditAttribution: joshtaylor at Josh Taylor Development for Bonsai Bookings commentedPR submitted at https://github.com/commerceguys/commerce/pull/227 .
Comment #5
joshtaylor CreditAttribution: joshtaylor at Josh Taylor Development for Bonsai Bookings commentedComment #6
joshtaylor CreditAttribution: joshtaylor at Josh Taylor Development for Bonsai Bookings commentedTest breakage not related to this issue.
Comment #7
dbolinovski CreditAttribution: dbolinovski commentedhook_rebuild() implementation.
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedCommitted: https://github.com/commerceguys/commerce/commit/f2d874806929956acfda1a5f...