1 min read

Product Service (aka PDP)

ProductService is found in Poq.Sfcc.Integration.Services namespace. It requires several dependencies to be used in your backend. All required dependencies should be registered using IoC:

services.AddScoped<IProductService, ProductService>();
services.AddScoped<IProductClient, ProductClient>();
services.AddScoped<IProductsResourceClient, ProductsResourceClient>();
services.AddScoped<IProductsListMerger, ProductsListMerger>();
services.AddScoped<IProductMerger, ProductMerger>();

Explanation of services:

  • IProductClient is available as part of Poq nuget package. No further action is required than properly registering the service.

  • IProductsResourceClient is available as part of Sfcc Sdk. docs.

  • IProductService with implementation ProductService Product service is responsible of obtaining Feed product data & product data from OCAPI. It later uses provided IProductsListMerger to merge data from both sources.

  • IProductsListMerger with implementation ProductsListMerger merges lists of Poq.Products with list of SfccProducts. Mappings are created based on SfccProduct.Type. Normally this service should be used out the box for most implementations. If required, it is possible to create and register a custom implementation of IProductsListMerger.

  • IProductMerger with implementation ProductMerger merges Poq.ProductVariant with SfccVariant or SfccProduct. This service updates the information in PoqVariant with the one provided from OCAPI. Updates: Prices, Quantity, Availability, Options. This would be the perfect place to apply customized mapping of information from OCAPI by providing a customized implementation of IProductMerger.

Here in an example of overriding default handling in ProductMerger.

services.AddScoped<IProductMerger, MyCustomProductMerger>();
public class MyCustomProductMerger : ProductMerger
public override Task<ProductVariant> UpdatePoqVariantWithSfccData(ProductVariant variant, SfccVariant? sfccVariant, SfccProduct? sfccProduct, string? currency = null)
{
var result = base.UpdatePoqVariantWithSfccData(variant, sfccVariant, sfccProduct, currency);
// Custom updates of result
return result;
}

When customizing the ProductService for your particular use case, take into consideration that the more interfaces you have to implement, the more complex your code will become. It may be preferable to introduce a completely bespoke implementation, rather than extensively customizing the default behavior.