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);
        
Home | Imprint | This part of the site doesn't use cookies.