Skip to content

Commit

Permalink
Merge pull request #9 from k-aleksandar/master
Browse files Browse the repository at this point in the history
Multisite handle fix
  • Loading branch information
kevinmeijer97 authored Nov 13, 2024
2 parents b001957 + 391f934 commit 1de3653
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Actions/HarvestReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Statamic\Entries\Entry as StatamicEntry;
use Statamic\Facades\Entry;
use Statamic\Facades\GlobalSet;
use Statamic\Facades\Site;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

class HarvestReviews
Expand Down Expand Up @@ -133,7 +134,7 @@ protected function saveReviews(?array $reviews)
'name' => $review['client']['name'],
'questions' => $questions,
'product' => $review['product'],
], $review['id'], 'default');
], $review['id'], Site::default()->handle());
}
}

Expand All @@ -143,16 +144,18 @@ protected function updateTotals()
return;
}

$site = Site::default()->handle();

$average_score = round($this->totalScore / $this->totalCount, 1);
$recommendation_percentage = round($this->totalRecommends / $this->totalCount * 100);

$set = GlobalSet::findByHandle('reviews');
if (! $set || ! $set->localizations()['default']) {
if (! $set || ! $set->localizations()[$site]) {
return;
}

$set->localizations()['default']->average_score = $average_score;
$set->localizations()['default']->recommendation_percentage = $recommendation_percentage;
$set->localizations()[$site]->average_score = $average_score;
$set->localizations()[$site]->recommendation_percentage = $recommendation_percentage;
$set->save();

Cache::forget('feedback-company-data');
Expand Down

0 comments on commit 1de3653

Please sign in to comment.