getSetgroups example

// if we have set a custom setgroup scope, then the group id         // is used as suffix in the scopeKey...         if ($discount->isScopeSetGroup()) {
            $payload['groupId'] = $discount->getSetGroupId();
            $payload['discountScope'] = PromotionDiscountEntity::SCOPE_SETGROUP;
        }

        // add all our set groups to our configuration         // if existing. always make sure to have at least a node         $payload['setGroups'] = [];

        if ($promotion->getSetgroups() !== null) {
            foreach ($promotion->getSetgroups() as $group) {
                $payload['setGroups'][] = [
                    'groupId' => $group->getId(),
                    'packagerKey' => $group->getPackagerKey(),
                    'value' => $group->getValue(),
                    'sorterKey' => $group->getSorterKey(),
                    'rules' => $group->getSetGroupRules(),
                ];
            }
        }

        
$payload = $ruleEntity->getPayload();
                if ($payload instanceof Rule) {
                    $cartOR->addRule($payload);
                }
            }

            $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(),
                        
Home | Imprint | This part of the site doesn't use cookies.