commerce_product_entity_info

  1. commerce
    1. 7
Versions
7 commerce_product_entity_info()

Implements hook_entity_info().

Code

modules/product/commerce_product.module, line 72

<?php
function commerce_product_entity_info() {
  $return = array(
    'commerce_product' => array(
      'label' => t('Commerce Product'), 
      'controller class' => 'CommerceProductEntityController', 
      'base table' => 'commerce_product', 
      'fieldable' => TRUE, 
      'entity keys' => array(
        'id' => 'product_id', 
        'bundle' => 'type', 
        'label' => 'title',
      ), 
      'bundle keys' => array(
        'bundle' => 'type',
      ), 
      'bundles' => array(), 
      'load hook' => 'commerce_product_load', 
      'view modes' => array(
        'full' => array(
          'label' => t('Admin display'), 
          'custom settings' => FALSE,
        ),
      ), 
      'uri callback' => 'commerce_product_uri', 
      'metadata controller class' => '', 
      'token type' => 'commerce-product', 
      'access callback' => 'commerce_entity_access', 
      'access arguments' => array(
        'user key' => 'uid', 
        'access tag' => 'commerce_product_access',
      ), 
      'permission labels' => array(
        'singular' => t('product'), 
        'plural' => t('products'),
      ),
      // Add translation support. 
      'translation' => array(
        'locale' => TRUE, 
        'entity_translation' => array(
          'class' => 'EntityTranslationCommerceProductHandler',
        ),
      ),
      // Add title replacement support for translations. 
      'field replacement' => array(
        'title' => array(
          'field' => array(
            'type' => 'text', 
            'cardinality' => 1, 
            'translatable' => TRUE,
          ), 
          'instance' => array(
            'label' => t('Title'), 
            'required' => TRUE, 
            'settings' => array(
              'text_processing' => 0,
            ), 
            'widget' => array(
              'weight' => -5,
            ),
          ),
        ),
      ),
    ),
  );

  foreach (commerce_product_type_get_name() as $type => $name) {
    $return['commerce_product']['bundles'][$type] = array(
      'label' => $name,
    );
  }

  return $return;
}
?>