function commerce_stock_local_install in Commerce Stock 8
Implements hook_install().
File
- modules/
local_storage/ commerce_stock_local.install, line 240 - Contains install and update functions for commerce stock local.
Code
function commerce_stock_local_install() {
$db = \Drupal::database();
// Add core transaction types.
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 1,
'name' => 'Stock in',
'parent_id' => 1,
])
->execute();
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 2,
'name' => 'Stock Out',
'parent_id' => 2,
])
->execute();
// Add sub transaction types.
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 4,
'name' => 'Sale',
'parent_id' => 2,
])
->execute();
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 5,
'name' => 'Return',
'parent_id' => 1,
])
->execute();
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 6,
'name' => 'New Stock',
'parent_id' => 1,
])
->execute();
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 7,
'name' => 'Move From',
'parent_id' => 2,
])
->execute();
$db
->insert('commerce_stock_transaction_type')
->fields([
'id' => 8,
'name' => 'Move To',
'parent_id' => 1,
])
->execute();
$defaultStockLocation = StockLocation::create([
'name' => 'Main',
'status' => TRUE,
'type' => "default",
]);
$defaultStockLocation
->save();
}