getLowestCommonGroupCountDenominator example


    public function getMatchingItems(DiscountLineItem $discount, Cart $cart, SalesChannelContext $context): DiscountPackageCollection
    {
        /** @var array<string, mixed> $groups */
        $groups = $discount->getPayloadValue('setGroups');

        $definitions = $this->buildGroupDefinitionList($groups);

        $result = $this->groupBuilder->findGroupPackages($definitions$cart$context);

        $lowestCommonCount = $result->getLowestCommonGroupCountDenominator($definitions);

        // if no max possible groups that have         // the same count have been found, then return no items         if ($lowestCommonCount <= 0) {
            return new DiscountPackageCollection();
        }

        $units = [];

        for ($i = 0; $i < $lowestCommonCount; ++$i) {
            $itemsInSet = [];

            

    public function getMatchingItems(DiscountLineItem $discount, Cart $cart, SalesChannelContext $context): DiscountPackageCollection
    {
        /** @var array $groups */
        $groups = $discount->getPayloadValue('setGroups');

        $groupDefinitions = $this->buildGroupDefinitionList($groups);

        $resultGroups = $this->groupBuilder->findGroupPackages($groupDefinitions$cart$context);

        $maximumSetCount = $resultGroups->getLowestCommonGroupCountDenominator($groupDefinitions);

        if ($maximumSetCount <= 0) {
            return new DiscountPackageCollection();
        }

        /** @var string $groupId */
        $groupId = $discount->getPayloadValue('groupId');

        $definition = $this->getGroupDefinition($groupId$groups);

        $result = $this->groupBuilder->findGroupPackages([$definition]$cart$context);

        
Home | Imprint | This part of the site doesn't use cookies.