Skip to content

Commit b2ee015

Browse files
Updated product adapter docs
1 parent 54705d3 commit b2ee015

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

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

Lines changed: 7 additions & 8 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` methods that retrieve a Product Snapshot for either a product or 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.
@@ -170,6 +165,10 @@ public interface IProductVariantSnapshot
170165

171166
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.
172167

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 obsoletion warning, please ignore this. It is used to promote the use of the `ProductAdapterBase` base class.
170+
{% endhint %}
171+
173172
```csharp
174173
public static class UmbracoCommerceUmbracoBuilderExtensions
175174
{

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` methods that retrieve a Product Snapshot for either a product or 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 obsoletion warning, please 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` methods that retrieve a Product Snapshot for either a product or 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 obsoletion warning, please 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)