diff --git a/src/services/BlockUsageService.php b/src/services/BlockUsageService.php index e9d2315..e915bb0 100755 --- a/src/services/BlockUsageService.php +++ b/src/services/BlockUsageService.php @@ -105,7 +105,10 @@ public function getCounts(int $fieldId) foreach($field->getEntryTypes() as $entryType) { - $entries = Entry::find()->typeId($entryType->id)->status(null)->collect(); + $entries = Entry::find() + ->site(Craft::$app->request->get('site') ?? Craft::$app->sites->primarySite->handle) + ->typeId($entryType->id) + ->collect(); $topLevelEntries = $entries->map(function($entry){ try { @@ -118,7 +121,7 @@ public function getCounts(int $fieldId) } catch(Exception $e) { return $entry; } - })->unique(); + })->unique('canonicalId'); $labelHtml = $this->_getEntryTypeLabel($entryType); $_blocks[] = [ @@ -169,7 +172,11 @@ public function getEntryTypeEntries(int $fieldId, int $entryTypeId) ]; } - $entries = Entry::find()->typeId($entryType->id)->status(null)->collect(); + $entries = Entry::find() + ->site(Craft::$app->request->get('site') ?? Craft::$app->sites->primarySite->handle) + ->typeId($entryType->id) + ->status(null) + ->collect(); $topLevelEntries = $entries ->filter(function($entry) use ($fieldId){ @@ -190,7 +197,7 @@ public function getEntryTypeEntries(int $fieldId, int $entryTypeId) return $entry; } }) - ->unique(); + ->unique('canonicalId'); $labelHtml = $this->_getEntryTypeLabel($entryType); return [