In a previous article we presented a list of properties per content entity in Drupal core and some contributed modules. This time we will provide a similar list for Drupal Commerce. When migrating into content entities, these define several properties that can be included in the `process` section to populate their values. For example, when importing Drupal Commerce product variations you can specify the SKU, price, list price, etc. In the case of promotions, you can set the start and end dates. Finding out which properties are available for an entity might require some Drupal development knowledge. To make the process easier, in today’s article we are presenting a reference of properties available in content entities provided by Drupal Commerce and some related contributed modules.
For each entity we will present: the module that provides it, the class that defines it, and the available properties. For each property we will list its name, field type, a description, and a note if the field allows unlimited values (i.e. it has an unlimited cardinality). The list of properties available for a content entity depend on many factors. For example, if the entity is revisionable (e.g. `revision_default`), translatable (e.g. `langcode`), or both (e.g. `revision_translation_affected`). The modules that are enabled on the site can also affect the available properties. For instance, if the “Workspaces” module is installed, it will add a `workspace` property to many content entities. This reference assumes that Drupal was installed using the `standard` installation profile and only Drupal Commerce related modules that provide content entities are enabled.
It is worth noting that entity properties are divided in two categories: base field definitions and field storage configurations. Base field configurations will always be available for the entity. On the other hand, the presence of field storage configurations will depend on various factors. For one, they can only be added to fieldable entities. Attaching the fields to the entity can be done manually by the user, by a module, or by an installation profile. Again, this reference assumes that Drupal was installed using the `standard` installation profile with Drupal Commerce related modules enabled. By default, the `commerce_product` entity adds a `body`field. For entities that can have multiple bundles, not all properties provided by the field storage configurations will be available in all bundles. For example, with the `standard` installation profile all content types will have a `body` field associated with it, but only the `article` content type has the `field_image`, and `field_tags` fields. If subfields are available for the field type, you can migrate into them.
If you are migrating into Drupal Commerce, make sure to check the Commerce Migrate module. It offers migrate destination field handlers for commerce fields and a plugin for commerce product types. It also provides a migration path from Commerce 1 (Drupal 7), Ubercart, and other e-commerce platforms. It is even possible to import data from other platforms like WooCommerce, Magento, and Shopify via CSV exports.
Store entity
Module: Commerce Store (part of commerce module)
Class: Drupal\commerce_store\Entity\Store
List of base field definitions:
- store_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- type: (entity_reference to commerce_store_type) Type. The store type.
- uid: (entity_reference to user) Owner. The store owner.
- name: (string) Name. The store name.
- mail: (email) Email. Store email notifications are sent from this address.
- default_currency: (entity_reference to commerce_currency) Default currency. The default currency of the store.
- timezone: (list_string) Timezone. Used when determining promotion and tax availability.
- address: (address) Address. The store address.
- billing_countries: (list_string) Supported billing countries. Allows unlimited values.
- path: (path) URL alias. The store URL alias.
- is_default: (boolean) Default. Whether this is the default store.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
- shipping_countries: (list_string) Supported shipping countries. Allows unlimited values.
- prices_include_tax: (boolean) Prices are entered with taxes included..
- tax_registrations: (list_string) Tax registrations. The countries where the store is additionally registered to collect taxes. Allows unlimited values.
Product entity
Module: Commerce Product (part of commerce module)
Class: Drupal\commerce_product\Entity\Product
List of base field definitions:
- product_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- type: (entity_reference to commerce_product_type) Product type.
- status: (boolean) Published.
- stores: (entity_reference to commerce_store) Stores. The product stores. Allows unlimited values.
- uid: (entity_reference to user) Author. The product author.
- title: (string) Title. The product title.
- variations: (entity_reference to commerce_product_variation) Variations. The product variations. Allows unlimited values.
- created: (created) Created. The time when the product was created.
- changed: (changed) Changed. The time when the product was last edited.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
List of field storage configurations:
- body: text_with_summary field.
Product variation entity
Module: Commerce Product (part of commerce module)
Class: Drupal\commerce_product\Entity\ProductVariation
List of base field definitions:
- variation_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- type: (entity_reference to commerce_product_variation_type) Product variation type.
- status: (boolean) Published.
- uid: (entity_reference to user) Author. The variation author.
- product_id: (entity_reference to commerce_product) Product. The parent product.
- sku: (string) SKU. The unique, machine-readable identifier for a variation.
- title: (string) Title. The variation title.
- list_price: (commerce_price) List price. The list price.
- price: (commerce_price) Price. The price
- created: (created) Created. The time when the variation was created.
- changed: (changed) Changed. The time when the variation was last edited.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
Product attribute value entity
Module: Commerce Product (part of commerce module)
Class: Drupal\commerce_product\Entity\ProductAttributeValue
List of base field definitions:
- attribute_value_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- attribute: (entity_reference to commerce_product_attribute) Attribute.
- name: (string) Name. The attribute value name.
- weight: (integer) Weight. The weight of this attribute value in relation to others.
- created: (created) Created. The time when the attribute value was created.
- changed: (changed) Changed. The time when the attribute value was last edited.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
Order entity
Module: Commerce Order (part of commerce module)
Class: Drupal\commerce_order\Entity\Order
List of base field definitions:
- order_id: (integer) ID.
- uuid: (uuid) UUID.
- type: (entity_reference to commerce_order_type) Order type.
- order_number: (string) Order number. The order number displayed to the customer.
- store_id: (entity_reference to commerce_store) Store. The store to which the order belongs.
- uid: (entity_reference to user) Customer. The customer.
- mail: (email) Contact email. The email address associated with the order.
- ip_address: (string) IP address. The IP address of the order.
- billing_profile: (entity_reference_revisions) Billing information. Billing profile
- order_items: (entity_reference to commerce_order_item) Order items. The order items. Allows unlimited values.
- adjustments: (commerce_adjustment) Adjustments. Allows unlimited values.
- total_price: (commerce_price) Total price. The total price of the order.
- total_paid: (commerce_price) Total paid. The total paid price of the order.
- state: (state) State. The order state.
- data: (map) Data. A serialized array of additional data.
- locked: (boolean) Locked.
- created: (created) Created. The time when the order was created.
- changed: (changed) Changed. The time when the order was last edited.
- placed: (timestamp) Placed. The time when the order was placed.
- completed: (timestamp) Completed. The time when the order was completed.
- cart: (boolean) Cart.
- checkout_flow: (entity_reference to commerce_checkout_flow) Checkout flow.
- checkout_step: (string) Checkout step.
- payment_gateway: (entity_reference to commerce_payment_gateway) Payment gateway. The payment gateway.
- payment_method: (entity_reference to commerce_payment_method) Payment method. The payment method.
- coupons: (entity_reference to commerce_promotion_coupon) Coupons. Coupons which have been applied to order. Allows unlimited values.
Order item entity
Module: Commerce Order (part of commerce module)
Class: Drupal\commerce_order\Entity\OrderItem
List of base field definitions:
- order_item_id: (integer) ID.
- uuid: (uuid) UUID.
- type: (entity_reference to commerce_order_item_type) Order item type.
- order_id: (entity_reference to commerce_order) Order. The parent order.
- purchased_entity: (entity_reference to node) Purchased entity. The purchased entity.
- title: (string) Title. The order item title.
- quantity: (decimal) Quantity. The number of purchased units.
- unit_price: (commerce_price) Unit price. The price of a single unit.
- overridden_unit_price: (boolean) Overridden unit price. Whether the unit price is overridden.
- total_price: (commerce_price) Total price. The total price of the order item.
- adjustments: (commerce_adjustment) Adjustments. Allows unlimited values.
- uses_legacy_adjustments: (boolean) Uses legacy adjustments.
- data: (map) Data. A serialized array of additional data.
- created: (created) Created. The time when the order item was created.
- changed: (changed) Changed. The time when the order item was last edited.
Payment method entity
Module: Commerce Payment (part of commerce module)
Class: Drupal\commerce_payment\Entity\PaymentMethod
List of base field definitions:
- method_id: (integer) ID.
- uuid: (uuid) UUID.
- type: (string) Payment method type.
- payment_gateway: (entity_reference to commerce_payment_gateway) Payment gateway. The payment gateway.
- payment_gateway_mode: (string) Payment gateway mode. The payment gateway mode.
- uid: (entity_reference to user) Owner. The payment method owner.
- remote_id: (string) Remote ID. The payment method remote ID.
- billing_profile: (entity_reference_revisions) Billing profile. Billing profile
- reusable: (boolean) Reusable. Whether the payment method is reusable.
- is_default: (boolean) Default. Whether this is the user’s default payment method.
- expires: (timestamp) Expires. The time when the payment method expires. 0 for never.
- created: (created) Created. The time when the payment method was created.
- changed: (changed) Changed. The time when the payment method was last edited.
Payment entity
Module: Commerce Payment (part of commerce module)
Class: Drupal\commerce_payment\Entity\Payment
List of base field definitions:
- payment_id: (integer) ID.
- uuid: (uuid) UUID.
- type: (string) Payment type.
- payment_gateway: (entity_reference to commerce_payment_gateway) Payment gateway. The payment gateway.
- payment_gateway_mode: (string) Payment gateway mode. The payment gateway mode.
- payment_method: (entity_reference to commerce_payment_method) Payment method. The payment method.
- order_id: (entity_reference to commerce_order) Order. The parent order.
- remote_id: (string) Remote ID. The remote payment ID.
- remote_state: (string) Remote State. The remote payment state.
- amount: (commerce_price) Amount. The payment amount.
- refunded_amount: (commerce_price) Refunded amount. The refunded payment amount.
- state: (state) State. The payment state.
- authorized: (timestamp) Authorized. The time when the payment was authorized.
- expires: (timestamp) Expires. The time when the payment expires. 0 for never.
- completed: (timestamp) Completed. The time when the payment was completed.
- test: (boolean) Test. Whether this is a test payment.
- captured: (timestamp) Captured. The time when the payment was captured.
Module: Commerce Promotion (part of commerce module)
Class: Drupal\commerce_promotion\Entity\Promotion
List of base field definitions:
- promotion_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- name: (string) Name. The promotion name.
- display_name: (string) Display name. If provided, shown on the order instead of “Discount”.
- description: (string_long) Description. Additional information about the promotion to show to the customer
- order_types: (entity_reference to commerce_order_type) Order types. The order types for which the promotion is valid. Allows unlimited values.
- stores: (entity_reference to commerce_store) Stores. The stores for which the promotion is valid. Allows unlimited values.
- offer: (commerce_plugin_item:commerce_promotion_offer) Offer type.
- conditions: (commerce_plugin_item:commerce_condition) Conditions. Allows unlimited values.
- condition_operator: (list_string) Condition operator. The condition operator.
- coupons: (entity_reference to commerce_promotion_coupon) Coupons. Coupons which allow promotion to be redeemed. Allows unlimited values.
- usage_limit: (integer) Usage limit. The maximum number of times the promotion can be used. 0 for unlimited.
- start_date: (datetime) Start date. The date the promotion becomes valid.
- end_date: (datetime) End date. The date after which the promotion is invalid.
- compatibility: (list_string) Compatibility with other promotions.
- status: (boolean) Status. Whether the promotion is enabled.
- weight: (integer) Weight. The weight of this promotion in relation to others.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
Module: Commerce Promotion (part of commerce module)
Class: Drupal\commerce_promotion\Entity\Coupon
List of base field definitions:
- id: (integer) ID.
- uuid: (uuid) UUID.
- promotion_id: (entity_reference to commerce_promotion) Promotion. The parent promotion.
- code: (string) Coupon code. The unique, machine-readable identifier for a coupon.
- usage_limit: (integer) Usage limit. The maximum number of times the coupon can be used. 0 for unlimited.
- status: (boolean) Status. Whether the coupon is enabled.
Log entity
Module: Commerce Log (part of commerce module)
Class: Drupal\commerce_log\Entity\Log
List of base field definitions:
- log_id: (integer) ID.
- uuid: (uuid) UUID.
- uid: (entity_reference to user) User. The user for the log.
- template_id: (string) Log template ID. The log template plugin ID
- category_id: (string) Log category ID. The log category plugin ID
- source_entity_id: (integer) Source entity ID. The source entity ID
- source_entity_type: (string) Source entity type. The source entity type
- params: (map) Params. A serialized array of parameters for the log template.
- created: (created) Created. The time when the log was created.
Price list entity
Module: Commerce Pricelist
Class: Drupal\commerce_pricelist\Entity\PriceList
List of base field definitions:
- id: (integer) ID.
- uuid: (uuid) UUID.
- type: (string) Price list bundle.
- uid: (entity_reference to user) Owner. The user that owns this price list.
- name: (string) Name. The name of the price list.
- stores: (entity_reference to commerce_store) Stores. The stores for which the price list is valid. Allows unlimited values.
- customer: (entity_reference to user) Customer. The customer for which the price list is valid.
- customer_roles: (entity_reference to user_role) Customer roles. The customer roles for which the price list is valid. Allows unlimited values.
- start_date: (datetime) Start date. The date the price list becomes valid.
- end_date: (datetime) End date. The date after which the price list is invalid.
- weight: (integer) Weight. The weight of this price list in relation to other price lists.
- status: (boolean) Status. Whether the price list is enabled.
- changed: (changed) Changed. The time when the price list was last edited.
Price list item entity
Module: Commerce Pricelist
Class: Drupal\commerce_pricelist\Entity\PriceListItem
List of base field definitions:
- id: (integer) ID.
- uuid: (uuid) UUID.
- type: (string) Price list item bundle.
- uid: (entity_reference to user) Owner. The user that owns this price list item.
- price_list_id: (entity_reference to commerce_pricelist) Price list. The parent price list.
- purchasable_entity: (entity_reference to commerce_product_variation) Purchasable entity. The purchasable entity.
- quantity: (decimal) Quantity. The quantity tier.
- list_price: (commerce_price) List price. The list price.
- price: (commerce_price) Price. The price.
- status: (boolean) Status. Whether the price list item is enabled.
- changed: (changed) Changed. The time when the price list item was last edited.
Shipment entity
Module: Shipping
Class: Drupal\commerce_shipping\Entity\Shipment
List of base field definitions:
- shipment_id: (integer) ID.
- uuid: (uuid) UUID.
- type: (entity_reference to commerce_shipment_type) Shipment type.
- order_id: (entity_reference to commerce_order) Order. The parent order.
- package_type: (string) Package type. The package type.
- shipping_method: (entity_reference to commerce_shipping_method) Shipping method. The shipping method
- shipping_service: (string) Shipping service. The shipping service.
- shipping_profile: (entity_reference_revisions) Shipping information.
- title: (string) Title. The shipment title.
- items: (commerce_shipment_item) Items. Allows unlimited values.
- weight: (physical_measurement) Weight.
- original_amount: (commerce_price) Original amount. The original amount.
- amount: (commerce_price) Amount. The amount.
- adjustments: (commerce_adjustment) Adjustments. Allows unlimited values.
- tracking_code: (string) Tracking code. The shipment tracking code.
- state: (state) State. The shipment state.
- data: (map) Data. A serialized array of additional data.
- created: (created) Created. The time when the shipment was created.
- changed: (changed) Changed. The time when the shipment was last updated.
- shipped: (timestamp) Shipped. The time when the shipment was shipped.
Shipping method entity
Module: Shipping
Class: Drupal\commerce_shipping\Entity\ShippingMethod
List of base field definitions:
- shipping_method_id: (integer) ID.
- uuid: (uuid) UUID.
- langcode: (language) Language.
- stores: (entity_reference to commerce_store) Stores. The stores for which the shipping method is valid. Allows unlimited values.
- plugin: (commerce_plugin_item:commerce_shipping_method) Plugin.
- name: (string) Name. The shipping method name.
- conditions: (commerce_plugin_item:commerce_condition) Conditions. Allows unlimited values.
- condition_operator: (list_string) Condition operator. The condition operator.
- weight: (integer) Weight. The weight of this shipping method in relation to others.
- status: (boolean) Enabled. Whether the shipping method is enabled.
- default_langcode: (boolean) Default translation. A flag indicating whether this is the default translation.
Available properties for other content entities
This reference includes Drupal Commerce content entities and some provided by related contributed modules. The previous article included a reference for Drupal core content entities. That being said, it would be impractical to cover all contributed modules. To get a list of yourself for other content entities, load the `entity_type.manager` service and call its `getFieldStorageDefinitions()` method passing the machine name of the entity as a parameter. Although this reference only covers content entities, the same process can be used for configuration entities.
What did you learn in today’s article? Did you know that there were so many entity properties provided Drupal Commerce? Were you aware that the list of available properties depend on factors like if the entity is fieldable, translatable, and revisionable? Did you know how to find properties for content entities from contributed modules? Please share your answers in the comments. Also, we would be grateful if you shared this article with your friends and colleagues.