I have noticed that when a component is localised, the GetItem(IEclUri) method is called on the ECL ProviderContext. In that method, I make a call to an external API using metadata of the current publication. However, if that call returns nothing, I need to perform that call again but using publication metadata of the publication owning the component being localised. However, I am unable to find a way to get to this information in the ProviderContext. The method only gets passed a IEclUri, which just contains the current publication ID. But I would like to know the current component being used (localised), so that I can get to its owning publication and use its metadata. Any ideas would be welcome.
You can't get the stub component URI from within GetItem.
There are a couple of workarounds that might work depending on your situation.
Persisting the stub URL
When the stub is being created you will receive a call to
IContextLibraryContext.StubComponentCreated. If you have means of storing this URI (forexample as metadata on the external system you can retrieve it as needed.
Calling a custom method on the provider.
IContextLibraryContext.GetItem is called on a lot of occasions, not just when an item is being localized. If you need something to happen on localize only you can implement a Tridion event handler executing when the item is being localized. You can then use
IDispatchHandler.Dispatch to make a custom call to the provider where you include any information you want.
IContentLibraryListItem inherits from the
IDispatchHandler interface, allowing you to make the
Dispatch call to your provider in general, or to a specific item.