Item set count per site

Hi,

On our item set browse pages, we include the item count per set using $itemSet->itemCount() but I just realized that this includes items across all sites, not limited to the particular site being used. Our items sets have items that are just in one site but then sometimes multiple. Is there a way to limit that count to just the particular site or would that require some sort of item search?

Thanks,

Joseph

There isn’t a single method that will do that, but you can get at that information:

$itemCount = $this->api()->search('items', ['item_set_id' => $itemSet->id(), 'site_id' => $this->currentSite()->id(), 'limit' => 0])->getTotalResults();

This is just the same as what itemCount() is doing but adding in the restriction to just things assigned to the current site.

Ok, great—many thanks :saluting_face: