 [ ← blog / drupal-commerce ](/) Jun 25, 2015  ·  \#drupal-commerce  ·  1 min read 

# Commerce entity's and storing arbitrary data



Drupal Commerce entities all make use of the "data" attribute. The data attribute is a blob that contain just about anything you would like - for example, Commerce Shipping utilizes this for shipping line items. Recently there was a [StackExchange question](http://drupal.stackexchange.com/questions/163176/where-is-documentation-for-entity-data-property-i-e-commerce-order-data) on the documentation of this attribute. The best way to learn about an entity (in Drupal 7) and how it operates is to review it's controller class, which each Commerce module has in its includes folder.

```
/**
 * Unserializes the data property of loaded orders.
 */
public function attachLoad(&$queried_orders, $revision_id = FALSE) {
  foreach ($queried_orders as $order_id => &$order) {
    $order->data = unserialize($order->data);
}
```

The database layer will always serialize items on save, but you're required to unserialize when returning data.

 

  ![](/themes/custom/mglaman/images/headshot.webp)Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.

 [Subscribe via RSS →](/rss.xml) [About me →](/about-me) 

 



 

  [← Older

Role Provisioner: Drupal 7 role and permission management

 ](/blog/role-provisioner-drupal-7-role-and-permission-management) [Newer →

Fixing "UpdaterException: Unable to determine the type of the source directory"

 ](/blog/fixing-updaterexception-unable-determine-type-source-directory)