LineItemGroupRule example

$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(),
            ]
        );

        $rule2 = new LineItemGroupRule();
        
$requirements->addRule($cartOR);
        }

        // verify if we are in SetGroup mode and build         // a custom setgroup rule for all groups         if ($this->isUseSetGroups() !== null && $this->isUseSetGroups() && $this->getSetgroups() !== null && $this->getSetgroups()->count() > 0) {
            // if we have groups, then all groups             // must match now to fulfill the new group definition in shopware promotions             $groupsRootRule = new AndRule();

            foreach ($this->getSetgroups() as $group) {
                $groupRule = new LineItemGroupRule();
                $groupRule->assign(
                    [
                        'groupId' => $group->getId(),
                        'packagerKey' => $group->getPackagerKey(),
                        'value' => $group->getValue(),
                        'sorterKey' => $group->getSorterKey(),
                        'rules' => $group->getSetGroupRules(),
                    ]
                );

                $groupsRootRule->addRule($groupRule);
            }
Home | Imprint | This part of the site doesn't use cookies.