You are here

public static function StockLevel::schema in Commerce Stock 8

Originally we had to define a real db field, because cores implementation of computed fields was brittle. During development of the module, we found, that we can "misuse" this to provide the possibility to enter initial stock values for newly created product variations.

Currently we use the column 'value' for exactly this one purpose. Don't get fooled by this. The calculation of the stock level is transaction based. The transactions have their own table.

Overrides FieldItemInterface::schema

File

modules/field/src/Plugin/Field/FieldType/StockLevel.php, line 42

Class

StockLevel
Plugin implementation of the 'commerce_stock_field' field type.

Namespace

Drupal\commerce_stock_field\Plugin\Field\FieldType

Code

public static function schema(FieldStorageDefinitionInterface $field_definition) {
  return [
    'columns' => [
      'value' => [
        'type' => 'numeric',
        'size' => 'normal',
        'precision' => 19,
        'scale' => 4,
        'not null' => FALSE,
      ],
    ],
  ];
}