Switching to the IPublishedStateAssessor.IsPublished() seems to work however a similiar issue is occuring where i want to check if their is a language fallback available that is published but since the page exists the ContentLoader returns the version that matches the country code but it is unpublished.
private bool IsFallbackAvailable(Guid contentGuid, CultureInfo language)
{
var loaderOptions = new LoaderOptions().Add(LanguageLoaderOption.Fallback(language));
if (!_contentLoader.TryGet(contentGuid, loaderOptions, out SitePageData page))
{
return false;
}
return _publishedStateAssessor.IsPublished(page);
}
It is apart of EpiServer.Cms.Shell IContentExtension I'm on CMS v12 but the docs only go up to CMS11.
I would say using IPublishedStateAssessor is the right approach as it also checks for IsPendingPublish and optinal conditions. I just looked into IsPublished and it simply checks if the content status is Published.
Also PublishedInLanguage is an extension in Find, you might want to write something else yourself to have more control over. for example. GetLanguageBranches to get content in all languages then IPublishedStateAssessor to see if each of them is published or not
Im using the content loader to find the Url for content in another language and if it doesn't exist i check if a fallback is available and will still route to that page. The problem is the page.IsPublished() and publishedInLanguages are returning true even though the the StartPublish is 2 days away.