public function getAutomaticPromotions(SalesChannelContext $context): EntityCollection
    {
        // add conditional OR filter to either get an entry that matches any existing rule,
        // or promotions that don't have ANY rules and thus are used globally
        $criteria = new Criteria([]);
        $criteria->addFilter(new MultiFilter(
            MultiFilter::CONNECTION_AND,
            [
                new EqualsFilter('useCodes', false),
                new EqualsFilter('active', true),
                new EqualsFilter('promotion.salesChannels.salesChannelId', $context->getSalesChannel()->getId()),
                $this->getDateRangeFilter(),
            ]
        ));

        $criteria->addAssociation('personaRules');
        $criteria->addAssociation('personaCustomers');
        $criteria->addAssociation('cartRules');
        $criteria->addAssociation('orderRules');
        $criteria->addAssociation('discounts');

        /* @var EntityCollection $result */
        $result = $this->promotionRepository->search($criteria, $context->getContext())->getEntities();

        return $result;
    }
public function getAutomaticPromotions(SalesChannelContext $context): EntityCollection
    {
        // add conditional OR filter to either get an entry that matches any existing rule,
        // or promotions that don't have ANY rules and thus are used globally
        $criteria = new Criteria([]);
        $criteria->addFilter(new MultiFilter(
            MultiFilter::CONNECTION_AND,
            [
                new EqualsFilter('useCodes', false),
                new EqualsFilter('active', true),
                new EqualsFilter('promotion.salesChannels.salesChannelId', $context->getSalesChannel()->getId()),
                $this->getDateRangeFilter(),
            ]
        ));

        $criteria->addAssociation('personaRules');
        $criteria->addAssociation('personaCustomers');
        $criteria->addAssociation('cartRules');
        $criteria->addAssociation('orderRules');
        $criteria->addAssociation('discounts');

        /* @var EntityCollection $result */
        $result = $this->promotionRepository->search($criteria, $context->getContext())->getEntities();

        return $result;
    }
public function getAutomaticPromotions ( SalesChannelContext $ context ) : EntityCollection { // add conditional OR filter to either get an entry that matches any existing rule, // or promotions that don't have ANY rules and thus are used globally $ criteria = new Criteria ( [ ] ) ; $ criteria -> addFilter ( new MultiFilter ( MultiFilter :: CONNECTION_AND , [ new EqualsFilter ( 'useCodes' , false ) , new EqualsFilter ( 'active' , true ) , new EqualsFilter ( 'promotion.salesChannels.salesChannelId' , $ context -> getSalesChannel ( ) -> getId ( ) ) , $ this -> getDateRangeFilter ( ) , ] ) ) ; $ criteria -> addAssociation ( 'personaRules' ) ; $ criteria -> addAssociation ( 'personaCustomers' ) ; $ criteria -> addAssociation ( 'cartRules' ) ; $ criteria -> addAssociation ( 'orderRules' ) ; $ criteria -> addAssociation ( 'discounts' ) ; /* @var EntityCollection $result */ $ result = $ this -> promotionRepository -> search ( $ criteria , $ context -> getContext ( ) ) -> getEntities ( ) ; return $ result ; }
Gets a list of all available active promotions that do not
require a code within the current checkout context.

@throws InconsistentCriteriaIdsException
@throws \Exception
Gets a list of all available active promotions that do not require a code within the current checkout context .