isUseIndividualCodes example

$repository = $this->getContainer()->get('promotion_individual_code.repository');
        $criteria = new Criteria();
        $criteria->addAssociation('promotion');
        /** @var PromotionIndividualCodeCollection $result */
        $result = $repository->search($criteria, Context::createDefaultContext())->getEntities();

        static::assertCount(10, $result);

        /** @var PromotionIndividualCodeEntity $promoCodeResult */
        foreach ($result as $promoCodeResult) {
            static::assertInstanceOf(PromotionEntity::class$promoCodeResult->getPromotion());
            static::assertTrue($promoCodeResult->getPromotion()->isUseIndividualCodes(), 'Promotion should have useIndividualCodes set to true after import');
        }

        // export         $progress = $this->export($context, PromotionIndividualCodeDefinition::ENTITY_NAME);

        static::assertImportExportSucceeded($progress$this->getInvalidLogContent($progress->getInvalidRecordsLogId()));

        $filesystem = $this->getContainer()->get('shopware.filesystem.private');
        $logfile = $this->getLogEntity($progress->getLogId())->getFile();
        static::assertInstanceOf(ImportExportFileEntity::class$logfile);
        $csv = $filesystem->read($logfile->getPath());

        
// set the discount type absolute, percentage, ...         $payload['discountType'] = $discount->getType();

        // set the code of this discount         $payload['code'] = $code;

        // set value of discount in payload         $payload['value'] = (string) $discount->getValue();

        // specifies the type of the promotion code (fixed, individual, global)         $promotionCodeType = 'fixed';
        if ($promotion->isUseIndividualCodes()) {
            $promotionCodeType = 'individual';
        }

        if ($code === '') {
            $promotionCodeType = 'global';
        }
        $payload['promotionCodeType'] = $promotionCodeType;

        // set our max value for maximum percentage discounts         $payload['maxValue'] = '';
        if ($discount->getType() === PromotionDiscountEntity::TYPE_PERCENTAGE && $discount->getMaxValue() !== null) {
            
Home | Imprint | This part of the site doesn't use cookies.