Skip to content

Commit 9126ac1

Browse files
authored
Merge pull request #7255 from mattbrailsford/uc-product-adapter-updates
Updated Umbraco Commerce Product Adapter docs to prevent confusion
2 parents 49c8c7f + f08432f commit 9126ac1

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

13/umbraco-commerce/key-concepts/product-adapters.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ What this means for developers is that Product Adapters allow you to hook in alt
1313
An example of a Product Adapter would look something like this:
1414

1515
```csharp
16-
public class MyCustomProductAdapter : IProductAdapter
16+
public class MyCustomProductAdapter : ProductAdapterBase
1717
{
18-
public IProductSnapshot GetProductSnapshot(string productReference, string languageIsoCode)
19-
{
20-
// Lookup a product by productReference and convert to IProductSnapshot
21-
}
22-
2318
public IProductSnapshot GetProductSnapshot(string productReference, string productVariantReference, string languageIsoCode)
2419
{
2520
// Lookup a product by productVariantReference and convert to IProductSnapshot
@@ -33,9 +28,9 @@ public class MyCustomProductAdapter : IProductAdapter
3328

3429
```
3530

36-
All Product Adapters implement the `IProductAdapter` interface which requires three method implementations:
31+
All Product Adapters implement the `ProductAdapterBase` base class which requires two method implementations:
3732

38-
* Two `GetProductSnapshot` methods that retrieve a Product Snapshot for either a product or product variant by reference parameters.
33+
* A `GetProductSnapshot` method that retrieves a Product Snapshot for either a product or a product variant by reference parameters.
3934
* A `TryGetProductReference` method which retrieves a product/variant reference for a product that belongs to a given `storeId` and has the given `sku`.
4035

4136
A Product Snapshot consists of the following properties in order to present a Product to Umbraco Commerce in a standard way.
@@ -168,7 +163,11 @@ public interface IProductVariantSnapshot
168163

169164
## Registering a Product Adapter
170165

171-
typeProduct Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
166+
Product Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
167+
168+
{% hint style="info" %}
169+
It is important that you register your product adapter via the `IProductAdapter` interface rather than the `ProductAdapterBase` class. If the `IProductAdapter` displays an obsolete warning, kindly ignore this. It is used to promote the use of the `ProductAdapterBase` base class.
170+
{% endhint %}
172171

173172
```csharp
174173
public static class UmbracoCommerceUmbracoBuilderExtensions

15/umbraco-commerce/key-concepts/product-adapters.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,24 @@ What this means for developers is that Product Adapters allow you to hook in alt
1313
An example of a Product Adapter would look something like this:
1414

1515
```csharp
16-
public class MyCustomProductAdapter : IProductAdapter
16+
public class MyCustomProductAdapter : ProductAdapterBase
1717
{
18-
public Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string languageIsoCode)
19-
{
20-
// Lookup a product by productReference and convert to IProductSnapshot
21-
}
22-
23-
public Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string productVariantReference, string languageIsoCode)
18+
public override Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string productVariantReference, string languageIsoCode)
2419
{
2520
// Lookup a product by productVariantReference and convert to IProductSnapshot
2621
}
2722

28-
Task<Attempt<(string ProductReference, string ProductVariantReference)>> TryGetProductReferenceAsync(Guid storeId, string sku)
23+
public override Task<Attempt<(string ProductReference, string ProductVariantReference)>> TryGetProductReferenceAsync(Guid storeId, string sku)
2924
{
3025
// Try lookup a product / variant reference by store + sku
3126
}
3227
}
3328

3429
```
3530

36-
All Product Adapters implement the `IProductAdapter` interface which requires three method implementations:
31+
All Product Adapters implement the `ProductAdapterBase` base class which requires two method implementations:
3732

38-
* Two `GetProductSnapshotAsync` methods that retrieve a Product Snapshot for either a product or product variant by reference parameters.
33+
* A `GetProductSnapshotAsync` method that retrieves a Product Snapshot for either a product or a product variant by reference parameters.
3934
* A `TryGetProductReferenceAsync` method which retrieves a product/variant reference for a product that belongs to a given `storeId` and has the given `sku`.
4035

4136
A Product Snapshot consists of the following properties in order to present a Product to Umbraco Commerce in a standard way.
@@ -168,7 +163,11 @@ public interface IProductVariantSnapshot
168163

169164
## Registering a Product Adapter
170165

171-
typeProduct Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
166+
Product Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
167+
168+
{% hint style="info" %}
169+
It is important that you register your product adapter via the `IProductAdapter` interface rather than the `ProductAdapterBase` class. If the `IProductAdapter` displays an obsolete warning, kindly ignore this. It is used to promote the use of the `ProductAdapterBase` base class.
170+
{% endhint %}
172171

173172
```csharp
174173
public static class UmbracoCommerceUmbracoBuilderExtensions

16/umbraco-commerce/key-concepts/product-adapters.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,24 @@ What this means for developers is that Product Adapters allow you to hook in alt
1313
An example of a Product Adapter would look something like this:
1414

1515
```csharp
16-
public class MyCustomProductAdapter : IProductAdapter
16+
public class MyCustomProductAdapter : ProductAdapterBase
1717
{
18-
public Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string languageIsoCode)
19-
{
20-
// Lookup a product by productReference and convert to IProductSnapshot
21-
}
22-
23-
public Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string productVariantReference, string languageIsoCode)
18+
public override Task<IProductSnapshot> GetProductSnapshotAsync(string productReference, string productVariantReference, string languageIsoCode)
2419
{
2520
// Lookup a product by productVariantReference and convert to IProductSnapshot
2621
}
2722

28-
Task<Attempt<(string ProductReference, string ProductVariantReference)>> TryGetProductReferenceAsync(Guid storeId, string sku)
23+
public override Task<Attempt<(string ProductReference, string ProductVariantReference)>> TryGetProductReferenceAsync(Guid storeId, string sku)
2924
{
3025
// Try lookup a product / variant reference by store + sku
3126
}
3227
}
3328

3429
```
3530

36-
All Product Adapters implement the `IProductAdapter` interface which requires three method implementations:
31+
All Product Adapters implement the `ProductAdapterBase` base class which requires two method implementations:
3732

38-
* Two `GetProductSnapshotAsync` methods that retrieve a Product Snapshot for either a product or product variant by reference parameters.
33+
* A `GetProductSnapshotAsync` method that retrieves a Product Snapshot for either a product or a product variant by reference parameters.
3934
* A `TryGetProductReferenceAsync` method which retrieves a product/variant reference for a product that belongs to a given `storeId` and has the given `sku`.
4035

4136
A Product Snapshot consists of the following properties in order to present a Product to Umbraco Commerce in a standard way.
@@ -168,7 +163,11 @@ public interface IProductVariantSnapshot
168163

169164
## Registering a Product Adapter
170165

171-
typeProduct Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
166+
Product Adapters are [registered via the IUmbracoCommerceBuilder](umbraco-commerce-builder.md) interface using the `AddUnique<IProductAdapter, TReplacementAdapter>()` method on the `Services` property. The `TReplacementAdapter` parameter is the type of our custom Product Adapter implementation.
167+
168+
{% hint style="info" %}
169+
It is important that you register your product adapter via the `IProductAdapter` interface rather than the `ProductAdapterBase` class. If the `IProductAdapter` displays an obsolete warning, kindly ignore this. It is used to promote the use of the `ProductAdapterBase` base class.
170+
{% endhint %}
172171

173172
```csharp
174173
public static class UmbracoCommerceUmbracoBuilderExtensions

0 commit comments

Comments
 (0)