Skip to content
commerce_product_ui.install 2.26 KiB
Newer Older
<?php

/**
 * Implements hook_install().
 */
function commerce_product_ui_install() {
  // Create the basic product type.
  $product_type = commerce_product_ui_product_type_new();

  $product_type['type'] = 'product';
  $product_type['name'] = t('Product');
  $product_type['description'] = t('A basic product type.');
  $product_type['is_new'] = TRUE;
  commerce_product_ui_product_type_save($product_type, FALSE);
}

/**
 * Implements hook_schema().
 */
function commerce_product_ui_schema() {
  $schema = array();

  $schema['commerce_product_type'] = array(
    'description' => 'Stores information about {commerce_product} types created via Product UI.',
    'fields' => array(
      'type' => array(
        'description' => 'The machine-readable name of this type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The human-readable name of this type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'A brief description of this type.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
      ),
      'help' => array(
        'description' => 'Help information shown to the user when creating a {commerce_product} of this type.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
      ),
      'revision' => array(
        'description' => 'Determine whether to create a new revision when a product of this type is updated.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
    ),
    'primary key' => array('type'),
  );

  return $schema;
}

/**
 * Add support for product revisions.
 */
function commerce_product_ui_update_7100() {
  $product_type_revision_spec = array(
    'description' => 'Determine whether to create a new revision when a product of this type is updated.',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 1,
  );
  db_add_field('commerce_product_type', 'revision', $product_type_revision_spec);

  return t('Support for product revisions has been added to product types.');
}