Episerver Commerce is a very flexible product that can be customized to suit every e-commerce business needs. Almost every aspect can be customized though the way IOC is implemented in the product. But because everything can be customized to suit your needs does not mean that it’s good at everything, the UI of Episerver Commerce, and mainly the Catalogue part of it is not a walk in the park to work with for everyone.
Because of this we have seen our fare share of importers as scheduled jobs or plugins to import a catalogue from a specialized application that is designed to maintain large volumes of product data and is specialized to work with this data.
The problem
The problem with importing large amount of products in Metadata Plus through the Service API via an import strategy is that it, most of all, is very time consuming. Has to be scheduled or even worse has to be triggered by hand. Another thing in general for importers is the validity of the data, when you have dynamic catalog data can already be old when the importer is finished.
The solution
The ideal solution would be that catalog data is retrieved through an API on the web that delivers the latest catalog data from a PIM or another data store.
Catalog content provider
We have implemented a CatalogContentProvider
that connects to an external API on the web to retrieve all catalog data in real time. Thus eliminating the usage of tedious import jobs. And always having fresh data. With all the benefits that come with it in the ever changing dynamic world of e-commerce.
If you are familiar to the term ContentProvider
then you can probably guess what a CatalogContentProvider
does. A ContentProvider
is a powerful integration method for extracting content from external sources and make it available in Episerver, and thus your website. For more information about the CatalogContentProvider
you can read the article on World about it.
If you like to know more about how we implemented the solution, the pittfalls we had to jump over and issues we had to resolve to make it all work please read along.
Where to start?
When you have implemented a ContentProvider
before then you probably assume that implementing a CatalogContentProvider
should be as straight forward as implementing a ContentProvider
. For a ContentProvider
implementation you retrieve your data, convert it to an IContent implementation and show it in the CMS under a specific node so the content editor can use it afterwhich it can be shown on your website. Basically a CatalogContentProvider
does exactly that for catalog data that is stored, in what in an Episerver world, is called MetaDataPlus. However it does come with some extra challenges;
Assigning a node where to show your catalog data is a little different and there are a few services that need to interact with your catalog data. For example, the PriceService
and InventoryService
need to be implemented. And in these services the ContentReference
is not used as ‘primary key’ (but the data in the Code
property is). You also have to implement a custom CatalogContentStructureProvider
. And the behaviour of the ReferenceConverter
. Last but not least you have to implement your own RelationRepository
.
Interception
We have re-implemented or intercepted the services above so they are backwards compatible, this means that for each catalog you can decide if you want to use the regular implementation where the catalog data is stored in the database, or the catalog data is retrieved from an external data source. Our implementation used a web API.
For more information about intercepting services in Episerver please read the article on World.
Step by step
We will go through the architecture, each service and explain what we have done in detail. We will go through the services above and we will also give some tips. For this blog post we have limit ourselves to the challenges for external catalog content providers. Basic knowledge about content providers in general is recommended.
Architecture
In a schema the whole thing looks like this;
Get started & examples
This whole collection of blog posts and the associated code repository is the result of a cooperation between my colleague Marc van de Wert and me. Together we have challenged each other to be as complete, clear, and simple as possible. Each day in the coming week we will post a chapter.
- The Catalog Content Provider
- References and Identities
- Relations, pricing and inventory
- Putting it all together
Together with this series we have prepared a working demo with a code base implemented in the Episerver foundation solution. If you are interested to dive deeper into this we are well willing to share the code base and help you further by implementing it in a real life scenario. In this case please contact us via our website. All code examples we refer to in this series are simplified and not meant for production environments.