Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getIndividualCodePattern example
public
function
addIndividualCodes
(
string
$promotionId
, int
$amount
, Context
$context
)
: void
{
$criteria
=
(
new
Criteria
(
[
$promotionId
]
)
)
->
addAssociation
(
'individualCodes'
)
;
/** @var PromotionEntity $promotion */
$promotion
=
$this
->promotionRepository->
search
(
$criteria
,
$context
)
->
first
(
)
;
if
(
$promotion
->
getIndividualCodes
(
)
=== null
)
{
$this
->
replaceIndividualCodes
(
$promotionId
,
$promotion
->
getIndividualCodePattern
(
)
,
$amount
,
$context
)
;
return
;
}
$newCodes
=
$this
->
generateIndividualCodes
(
$promotion
->
getIndividualCodePattern
(
)
,
$amount
,
$promotion
->
getIndividualCodes
(
)
->
getCodeArray
(
)
)
;
$codeEntries
=
$this
->
prepareCodeEntities
(
$promotionId
,
$newCodes
)
;