Skip to content

Commit 8962cdb

Browse files
MercuryKojobrusch
andauthored
Pimcore X provides TargetGroup Object in Action Array (#299)
* Pimcore X provides TargetGroup Object in Action Array Pimcore X now provides TargetGroup Object in Action Array instead of id also some isset checks for php8.1 * Update src/Targeting/ActionHandler/AssignTargetGroupAndSegment.php Co-authored-by: Bernhard Rusch <[email protected]>
1 parent 4a4bbbd commit 8962cdb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Targeting/ActionHandler/AssignTargetGroupAndSegment.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ public function apply(VisitorInfo $visitorInfo, array $action, Rule $rule = null
9595
}
9696

9797
$targetGroupId = $action['targetGroup'] ?? null;
98-
$targetGroup = TargetGroup::getById($targetGroupId);
98+
if ($targetGroupId instanceof TargetGroup) {
99+
$targetGroup = $targetGroupId;
100+
$targetGroupId = $targetGroup->getId();
101+
} else {
102+
$targetGroup = TargetGroup::getById($targetGroupId);
103+
}
99104

100-
if ($action['trackActivity'] && $targetGroup) {
105+
if (isset($action['trackActivity']) && $action['trackActivity'] && $targetGroup) {
101106
$totalWeight = $action['weight'];
102107
if ($visitorInfo->hasTargetGroupAssignment($targetGroup)) {
103108
$assignedTargetGroup = $visitorInfo->getTargetGroupAssignment($targetGroup);
@@ -107,7 +112,7 @@ public function apply(VisitorInfo $visitorInfo, array $action, Rule $rule = null
107112
$this->activityManager->trackActivity(new TargetGroupAssignActivity($customer, $targetGroup, $action['weight'], $totalWeight));
108113
}
109114

110-
if ($action['assignSegment'] == 'assign_only' || $action['assignSegment'] == 'assign_consider_weight') {
115+
if (isset($action['assignSegment']) && ($action['assignSegment'] == 'assign_only' || $action['assignSegment'] == 'assign_consider_weight')) {
111116

112117
//get segment based on target group
113118
$segments = $this->segmentManager->getSegments();

0 commit comments

Comments
 (0)