protected function processSkuGeneration($inventoryId, $code)
{
$this->dbStartTransaction();
try {
$sku = $this->sku()->getRelated()->newInstance();
$sku->setAttribute('inventory_id', $inventoryId);
$sku->setAttribute('code', $code);
if ($sku->save()) {
$this->dbCommitTransaction();
$this->fireEvent('inventory.sku.generated', ['item' => $this, 'sku' => $sku]);
return $sku;
}
} catch (\Exception $e) {
$this->dbRollbackTransaction();
}
return false;
}