Skip to content

Instantly share code, notes, and snippets.

@xuxucode
Created December 13, 2017 06:21
Show Gist options
  • Save xuxucode/60ea45ce5cd33ef08f202866b93ba7c5 to your computer and use it in GitHub Desktop.
Save xuxucode/60ea45ce5cd33ef08f202866b93ba7c5 to your computer and use it in GitHub Desktop.
Commerce order item purchased entity type
diff --git a/modules/order/commerce_order.info.yml b/modules/order/commerce_order.info.yml
index d7edcd74a..1c31916ba 100644
--- a/modules/order/commerce_order.info.yml
+++ b/modules/order/commerce_order.info.yml
@@ -11,6 +11,7 @@ dependencies:
- options
- profile
- state_machine
+ - commerce:commerce_product
config_devel:
install:
- commerce_order.commerce_order_type.default
diff --git a/modules/order/src/Entity/OrderItem.php b/modules/order/src/Entity/OrderItem.php
index 4cbfaa9c3..e278552b1 100644
--- a/modules/order/src/Entity/OrderItem.php
+++ b/modules/order/src/Entity/OrderItem.php
@@ -235,6 +235,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['purchased_entity'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Purchased entity'))
->setDescription(t('The purchased entity.'))
+ ->setSetting('target_type', 'commerce_product_variation')
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment