PermittedIndividualCodePromotions example

/** @var string $association */
                foreach ($this->requiredDalAssociations as $association) {
                    $globalCriteria->addAssociation($association);
                }

                /** @var PromotionCollection $foundPromotions */
                $foundPromotions = $this->gateway->get($globalCriteria$context);

                if (\count($foundPromotions->getElements()) <= 0) {
                    // no global code, so try with an individual code instead                     $individualCriteria = (new Criteria())->addFilter(new PermittedIndividualCodePromotions([$currentCode]$salesChannelId));

                    /** @var string $association */
                    foreach ($this->requiredDalAssociations as $association) {
                        $individualCriteria->addAssociation($association);
                    }

                    /** @var PromotionCollection $foundPromotions */
                    $foundPromotions = $this->gateway->get($individualCriteria$context);
                }

                // if we finally have found promotions add them to our list for the current code
/** * This test verifies, that we get the * expected and defined criteria from the template. * * @group promotions */
    public function testCriteria(): void
    {
        $codes = ['code-123'];

        $template = new PermittedIndividualCodePromotions($codes$this->salesChannel->getId());

        static::assertEquals($this->getExpectedFilter($codes)->getQueries()$template->getQueries());
    }

    /** * @param list<string> $codes */
    private function getExpectedFilter(array $codes): MultiFilter
    {
        return new MultiFilter(
            MultiFilter::CONNECTION_AND,
            [
Home | Imprint | This part of the site doesn't use cookies.