public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        // Generate a unique item key based on the current ID and customisations
        $key = base64_encode(json_encode($this->Customisations()->map("Title", "Value")->toArray()));
        $this->Key = $this->StockID . ':' . $key;
    }