getGroupResult example

return new DiscountPackageCollection();
        }

        $units = [];

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

            // now run through all definitions             // and check if our set and count is valid             foreach ($definitions as $definition) {
                $groupResult = $result->getGroupResult($definition);

                $itemsInGroup = $groupResult[$i]->getItems();

                $itemsInSet = array_merge($itemsInSet$itemsInGroup);
            }

            $units[] = new DiscountPackage(new LineItemQuantityCollection($itemsInSet));
        }

        $splitUnits = [];

        
$ruleEntity->setId(Uuid::randomHex());
        $ruleEntity->setPayload($rules);

        $group = $this->buildGroup(
            self::KEY_PACKAGER_COUNT,
            5,
            self::KEY_SORTER_PRICE_DESC,
            new RuleCollection([$ruleEntity])
        );

        $result = $this->unitTestBuilder->findGroupPackages([$group]$cart$this->context);
        $groupCount = $result->getGroupResult($group);

        static::assertCount(4, $groupCount);
    }

    /** * @group lineitemgroup */
    public function testShouldFindGroupsWithListPriceRule(): void
    {
        $cart = $this->buildCart(0);

        

    public function testGroupResultOnEmptyData(): void
    {
        $groupDefinition = new LineItemGroupDefinition('ID1', 'UNKNOWN', 2, 'PRICE_ASC', new RuleCollection());

        $result = new LineItemGroupBuilderResult();

        static::assertCount(0, $result->getGroupResult($groupDefinition));
    }

    /** * This test verifies that we get each single group result of a given group definition. * So our definition is being found 2 times with each 2 line items and their quantities. * * This is used to identify each group package later on and * allows us to e.g. only use the first valid group for discounts * instead of all found groups for a definition. * * @group lineitemgroup */
/** @var string $groupId */
        $groupId = $discount->getPayloadValue('groupId');

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

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

        $units = [];

        $addedGroupCount = 0;
        foreach ($result->getGroupResult($definition) as $group) {
            $singleItems = $this->splitQuantities($group->getItems());

            $units[] = new DiscountPackage(new LineItemQuantityCollection($singleItems));

            ++$addedGroupCount;

            if ($addedGroupCount === $maximumSetCount) {
                break;
            }
        }

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