protected function generateVoucherCodes($voucherId,
$numberOfUnits,
$codePattern) { $values =
[];
// wrote in standard sql cause in this case its way faster than doctrine models
$sql = 'INSERT IGNORE INTO s_emarketing_voucher_codes (voucherID, code) VALUES';
for ($i = 1;
$i <=
$numberOfUnits; ++
$i) { $code =
$this->
generateCode($codePattern);
$values[] =
Shopware()->
Db()->
quoteInto('(?)',
[$voucherId,
$code]);
// send the query every each 10000 times
if ($i % 10000 == 0 ||
$numberOfUnits ==
$i) { Shopware()->
Db()->
query($sql .
implode(',',
$values));
$values =
[];
} } } /**
* Helper function to get access to the voucher repository.
*
* @return Repository
*/