getPromotion example


    public function testPromotion(): void
    {
        $promotion1 = new PromotionEntity();

        $tuple = new PromotionCodeTuple('codeA', $promotion1);

        static::assertSame($promotion1$tuple->getPromotion());
    }
}
$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);
        
// check if max allowed redemption of promotion have been reached or not             // if max redemption has been reached promotion will not be added             $allPromotions = $this->getEligiblePromotionsWithDiscounts($allPromotions$context->getCustomer());

            $discountLineItems = [];
            $foundCodes = [];

            /** @var PromotionCodeTuple $tuple */
            foreach ($allPromotions->getPromotionCodeTuples() as $tuple) {
                // verify if the user might have removed and "blocked"                 // the promotion from being added again                 if ($cartExtension->isPromotionBlocked($tuple->getPromotion()->getId())) {
                    continue;
                }

                // lets build separate line items for each                 // of the available discounts within the current promotion                 $lineItems = $this->buildDiscountLineItems($tuple->getCode()$tuple->getPromotion()$original$context);

                // add to our list of all line items                 /** @var LineItem $nested */
                foreach ($lineItems as $nested) {
                    $discountLineItems[] = $nested;
                }
public function sGetProductByOrdernumber($ordernumber)
    {
        if (Shopware()->Events()->notifyUntil(
            'Shopware_Modules_Articles_sGetProductByOrdernumber_Start',
            ['subject' => $this, 'value' => $ordernumber]
        )) {
            return false;
        }

        return Shopware()->Events()->filter(
            'Shopware_Modules_Articles_sGetProductByOrdernumber_FilterResult',
            $this->getPromotion(null, $ordernumber),
            ['subject' => $this, 'value' => $ordernumber]
        );
    }

    /** * Get basic product data in various modes (firmly defined by id, random, top, new) * * @param string $mode Modus (fix, random, top, new) * @param int $category filter by category * @param int|string|numeric-string $value product id / order number for firmly defined products * @param bool $withImage * * @return array<string, mixed>|false */
Home | Imprint | This part of the site doesn't use cookies.