PromotionSetGroupCollection example

$group1->setId('g1');
        $group1->setPackagerKey('p1');
        $group1->setSorterKey('s1');
        $group1->setValue(1);

        $group2 = new PromotionSetGroupEntity();
        $group2->setId('g2');
        $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(
            [
                
$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',
            
Home | Imprint | This part of the site doesn't use cookies.