I'm following along the Umbraco Commerce documentation (13.latest) and registering a product adaptor does not actually work as described.
The docs express:
cs
public static class UmbracoCommerceUmbracoBuilderExtensions
{
public static IUmbracoCommerceBuilder AddMyServices(IUmbracoCommerceBuilder builder)
{
// Replacing the default Product Adapter implementation
builder.Services.AddUnique<ProductAdapterBase, MyCustomProductAdapter>();
// Return the builder to continue the chain
return builder;
}
}
Which is using the
ProductAdaptorBase
as the base class instead of
IProductAdaptor
(.. as is obsolete). But when inheriting from the base and trying to replace it doesn't actually allow me to register it, using the
IProductAdaptor
interface instead works as I expect it to.
Switching up my CustomProductAdaptor to inherit base and implement interface then also allows it to work like so:
cs
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddUmbracoCommerce(commerceBuilder =>
{
// works just fine
commerceBuilder.Services.AddUnique<IProductAdapter, ProductAdaptor>();
// does not work
// commerceBuilder.Services.AddUnique<ProductAdaptorBase, ProductAdaptor>();
})
So my final class impl looks like this:
cs
public class ProductAdaptor(IProductService productService, ICommerceApi commerceApi) : ProductAdapterBase, IProductAdapter
{
public override IProductSnapshot GetProductSnapshot(Guid storeId, string productReference, string languageIsoCode)
// rest removed for brevity
}
I think the intent is to actually inherit from the ABC and replace that
cs
public abstract class ProductAdapterBase : IProductAdapter
Have I wildly missed something? I'm a little miffed. The obsolete warnings are trigerring.
https://cdn.discordapp.com/attachments/1313875209203486771/1313875209828171836/image.png?ex=6751b924&is=675067a4&hm=c8327ccde8747128ed6cb98c671373708dc67923fbff054a2861e9ee1b46e415&