public function CreateVoucherCodes($sCode = null, $iNumberOfVouchers = null)
    {
        $oReturn = new stdClass();
        $oReturn->bError = false;
        $oReturn->sMessage = 'Gutscheine erstellt';

        if ($this->AllowCreatingVoucherCodes()) {
            $oGlobal = TGlobal::instance();
            if (is_null($iNumberOfVouchers)) {
                $iNumberOfVouchers = intval($oGlobal->GetUserData('iNumberOfVouchers'));
            }
            if (is_null($sCode)) {
                $sCode = $oGlobal->GetUserData('sCode');
            }
            $bUseRandomCode = (empty($sCode));

            if (!$bUseRandomCode) {
                // make sure that the code does not exist in another series
                $query = "SELECT * FROM `shop_voucher`
                     WHERE `shop_voucher_series_id` <> '".MySqlLegacySupport::getInstance()->real_escape_string($this->sId)."'
                       AND `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
                $tRes = MySqlLegacySupport::getInstance()->query($query);
                if (MySqlLegacySupport::getInstance()->num_rows($tRes) > 0) {
                    // invalid code
                    $oReturn->bError = true;
                    $oReturn->sMessage = 'Code wurde bereits in mindestens einer anderen Gutscheinserie verwendet!';
                }
            }
            if (!$oReturn->bError) {
                $oVoucher = TdbShopVoucher::GetNewInstance();
                /** @var $oVoucher TdbShopVoucher */
                $oVoucherCodeTableConf = &$oVoucher->GetTableConf();
                $oVoucherCodeEditor = new TCMSTableEditorManager();
                /** @var $oEditor TCMSTableEditorManager */
                $oVoucherCodeEditor->Init($oVoucherCodeTableConf->id, null);

                $oVoucher->AllowEditByAll(true);
                TCacheManager::SetDisableCaching(true);
                for ($i = 0; $i < $iNumberOfVouchers; ++$i) {
                    if ($bUseRandomCode) {
                        do {
                            $sCode = strtolower(TTools::GenerateVoucherCode(10));
                            if ($oVoucher->LoadFromFields(array('code' => $sCode))) {
                                $sCode = '';
                            }
                        } while (empty($sCode));
                    }
                    $aData = array('shop_voucher_series_id' => $this->sId, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
                    // save entrie...
                    $oVoucherCodeEditor->Save($aData);
                }
                TCacheManager::SetDisableCaching(false);
                TCacheManager::PerformeTableChange('shop_voucher', null); // flush all cache entries related to the voucher table
            }
        }

        return $oReturn;
    }