Skip to content

Commit

Permalink
Fix filtering contacts by segments
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Nov 29, 2024
1 parent 3e11315 commit 6668aad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for Campaign

## 1.26.1 - 2024-11-29

### Fixed

- Fixed a bug in which contacts could not be filtered by segments in non-primary sites ([#504](https://github.com/putyourlightson/craft-campaign/issues/504)).

## 1.26.0 - 2024-04-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "1.26.0",
"version": "1.26.1",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
3 changes: 2 additions & 1 deletion src/elements/ContactElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ protected static function defineSources(string $context = null): array
if (Campaign::$plugin->getIsPro()) {
$sources[] = ['heading' => Craft::t('campaign', 'Segments')];

$segments = SegmentElement::findAll();
$segments = Campaign::$plugin->segments->getAllSegments();

foreach ($segments as $segment) {
$sources[] = [
'key' => 'segment:'.$segment->id,
'label' => $segment->title,
'sites' => [$segment->siteId],
'data' => [
'id' => $segment->id
],
Expand Down
13 changes: 13 additions & 0 deletions src/services/SegmentsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ public function getSegmentsByIds(array $segmentIds): array
->all();
}

/**
* Returns all segments.
*
* @return SegmentElement[]
*/
public function getAllSegments(): array
{
/** @var SegmentElement[]] */
return SegmentElement::find()
->site('*')
->all();
}

/**
* Returns the segment's contacts
*
Expand Down

0 comments on commit 6668aad

Please sign in to comment.