setSetgroups example

$rule->setPayload((new LineItemUnitPriceRule())->assign(['amount' => 10, 'operator' => '=']));

        $ruleCollection = new RuleCollection([$rule]);

        $group = new PromotionSetGroupEntity();
        $group->setId(Uuid::randomBytes());
        $group->setPackagerKey('COUNT');
        $group->setValue(2);
        $group->setSorterKey('PRICE_ASC');
        $group->setSetGroupRules($ruleCollection);

        $this->promotion->setSetgroups(new PromotionSetGroupCollection([$group]));

        $builder = new PromotionItemBuilder();

        $item = $builder->buildDiscountLineItem('', $this->promotion, $discount, Defaults::CURRENCY, $currencyFactor);

        $expected = [
            'promotionId' => 'PR-1',
            'discountType' => 'percentage',
            'value' => '0',
            'maxValue' => '',
            'discountId' => 'P123',
            
$group2->setPackagerKey('p2');
        $group2->setSorterKey('s2');
        $group2->setValue(2);

        $groups = new PromotionSetGroupCollection();
        $groups->add($group1);
        $groups->add($group2);

        $promotion = new PromotionEntity();
        $promotion->setId('p1');
        $promotion->setUseSetGroups(true);
        $promotion->setSetgroups($groups);

        $rule1 = new LineItemGroupRule();
        $rule1->assign(
            [
                'groupId' => $group1->getId(),
                'packagerKey' => $group1->getPackagerKey(),
                'value' => $group1->getValue(),
                'sorterKey' => $group1->getSorterKey(),
                'rules' => $group1->getSetGroupRules(),
            ]
        );

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