You are here

uc_attribute.install in Ubercart 8.4

Install, update and uninstall functions for the uc_attribute module.

File

uc_attribute/uc_attribute.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the uc_attribute module.
 */

/**
 * Implements hook_schema().
 */
function uc_attribute_schema() {
  $schema = [];
  $schema['uc_attributes'] = [
    'description' => 'Attributes: the decisions that need to be made about products.',
    'fields' => [
      'aid' => [
        'description' => 'Primary key: attribute ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'name' => [
        'description' => 'Name of the attribute.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'label' => [
        'description' => 'Label to use when attribute is displayed.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'ordering' => [
        'description' => 'Determines the list position of attributes.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
      'required' => [
        'description' => 'Flag that, if set, requires a user response for attributes (disables default options).',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'display' => [
        'description' => 'Display type of the attribute options: 0 => text fields, 1 => select box (default), 2 => radio buttons.',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
      'description' => [
        'description' => 'Description of the attribute.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
    ],
    'primary key' => [
      'aid',
    ],
  ];
  $schema['uc_attribute_options'] = [
    'description' => 'The available choices for each attribute.',
    'fields' => [
      'aid' => [
        'description' => 'The {uc_attributes}.aid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'oid' => [
        'description' => 'Primary key: the option ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'name' => [
        'description' => 'The name of the option.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'cost' => [
        'description' => "The adjustment to a product's cost with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'price' => [
        'description' => "The adjustment to a product's price with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'weight' => [
        'description' => "The adjustment to a product's physical weight with the chosen option.",
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
      ],
      'ordering' => [
        'description' => 'Affects the list position of the options.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'oid',
    ],
    'indexes' => [
      'aid' => [
        'aid',
      ],
    ],
    'foreign keys' => [
      'uc_attributes' => [
        'table' => 'uc_attributes',
        'columns' => [
          'aid' => 'aid',
        ],
      ],
    ],
  ];
  $schema['uc_class_attributes'] = [
    'description' => 'Attributes copied to a product of a certain class when it is created.',
    'fields' => [
      'pcid' => [
        'description' => 'Primary key: the product {node}.type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ],
      'aid' => [
        'description' => 'The {uc_attributes}.aid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'label' => [
        'description' => 'Label to use when attribute is displayed.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'ordering' => [
        'description' => 'Determines the list position of attributes.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
      'default_option' => [
        'description' => 'The default value of the attribute field on the add to cart form.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'required' => [
        'description' => "A flag indicating that, if set, requires a user response for attributes (disables default options).",
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'display' => [
        'description' => 'Display type of the attribute options: 0 => text fields, 1 => select box (default), 2 => radio buttons',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
    ],
    'primary key' => [
      'pcid',
      'aid',
    ],
    'foreign keys' => [
      'uc_attributes' => [
        'table' => 'uc_attributes',
        'columns' => [
          'aid' => 'aid',
        ],
      ],
    ],
  ];
  $schema['uc_class_attribute_options'] = [
    'description' => 'The available choices for each attribute.',
    'fields' => [
      'pcid' => [
        'description' => 'Primary key: the product {node}.type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ],
      'oid' => [
        'description' => 'The {uc_attribute_options}.oid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'cost' => [
        'description' => "The adjustment to a product's cost with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'price' => [
        'description' => "The adjustment to a product's price with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'weight' => [
        'description' => "The adjustment to a product's physical weight with the chosen option.",
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
      ],
      'ordering' => [
        'description' => 'Affects the list position of the options.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'pcid',
      'oid',
    ],
    'foreign keys' => [
      'uc_attribute_options' => [
        'table' => 'uc_attribute_options',
        'columns' => [
          'oid' => 'oid',
        ],
      ],
    ],
  ];
  $schema['uc_product_attributes'] = [
    'description' => 'Attributes copied to a product.',
    'fields' => [
      'nid' => [
        'description' => 'The product {node}.nid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'aid' => [
        'description' => 'The {uc_attributes}.aid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'label' => [
        'description' => 'Label to use when attribute is displayed',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'ordering' => [
        'description' => 'Determines the list position of attributes.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
      'default_option' => [
        'description' => 'The default value of the attribute field on the add to cart form.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'required' => [
        'description' => "Flag that, if set, requires a user response for attributes (disables default options).",
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'display' => [
        'description' => 'Display type of the attribute options: 0 -- text fields, 1 -- select box (default), 2 -- radio buttons',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
    ],
    'primary key' => [
      'nid',
      'aid',
    ],
    'foreign keys' => [
      'uc_products' => [
        'table' => 'uc_products',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
      'uc_attributes' => [
        'table' => 'uc_attributes',
        'columns' => [
          'aid' => 'aid',
        ],
      ],
    ],
  ];
  $schema['uc_product_options'] = [
    'description' => 'The available choices for each attribute.',
    'fields' => [
      'nid' => [
        'description' => 'The product {node}.nid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'oid' => [
        'description' => 'The {uc_attribute_options}.oid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'cost' => [
        'description' => "The adjustment to a product's cost with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'price' => [
        'description' => "The adjustment to a product's price with the chosen option.",
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0,
      ],
      'weight' => [
        'description' => "The adjustment to a product's physical weight with the chosen option.",
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0,
      ],
      'ordering' => [
        'description' => 'Affects the list position of the options.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'nid',
      'oid',
    ],
    'foreign keys' => [
      'uc_products' => [
        'table' => 'uc_products',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
      'uc_attribute_options' => [
        'table' => 'uc_attribute_options',
        'columns' => [
          'oid' => 'oid',
        ],
      ],
    ],
  ];
  $schema['uc_product_adjustments'] = [
    'description' => "Changes to a product's SKU based on the possible combination of chosen options.",
    'fields' => [
      'nid' => [
        'description' => 'The product {node}.nid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'combination' => [
        'description' => 'A serialized array whose keys are attribute IDs and values are option IDs.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'serialize' => TRUE,
      ],
      'model' => [
        'description' => 'The SKU representing the product with the combination of options.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
    ],
    'foreign keys' => [
      'uc_products' => [
        'table' => 'uc_products',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
    ],
  ];
  return $schema;
}

Functions

Namesort descending Description
uc_attribute_schema Implements hook_schema().