I'm new to DXA and faced an unknown while fetching DCP (or to say EntityModel) from other Publication. I've a pre populated Localization object which points to current Publication/site context. How can I get a Localization object for a different Publication?
My requirement is to fetch EntityModels
from a different Publication then current!
I know, we get can EntityModel
for current Publication like this:
DefaultContentProvider contentProvider = new DefaultContentProvider();
EventDetail eventDataModel = null;
try
{
var eventData = contentProvider.GetEntityModel(new TcmUri(compId).ItemId + "-" + EventDetailCTID, _localization);
eventDataModel = eventData as EventDetail;
}
catch (Exception e)
{
// Error
}
How can we get a _localization
object for some other Publication?
Use Case: Every locale specific dynamic components are published from each publications. There is a webpage where we want to display all these dynamic components (from all geos), on a single page.
Update: I found a way of getting the localization object using Resolver: ILocalizationResolver localizationResolver = new CdApiLocalizationResolver(); _localization = localizationResolver.ResolveLocalization(new Uri());
I tried localizationResolver.GetLocalization(), but this doesnt seems to build the object.
SiteConfiguration.ContentProvider
andSiteConfiguration.LocalizationResolver
to get instances of configured types (dependency injection).