This document will explain Contentful CMS integration with SAP Commerce which includes implementation of Mulesoft as a Middleware for routing and transforming messages.
The behaviour of this implementation will work as a single application where content writers can insert some content for products and categories in Contentful which will be pushed to SAP Commerce passing through Mulesoft.
Contentful CMS Introduction
Contentful is all about content. From web apps to billboards, It makes sure that your content gets delivered via CDN in a flash. But before any content can be delivered to apps, It needs to create a data model for it. Much like a database table, a content model lets you define what type of content you want to store and once this is ready the content is delivered to other systems through Contentful REST APIs called as Content Delivery API(CDA) and Content Management API(CMA).
How This Integration Works
There's some explanation for the flow of integration defined below:
Content writer adds/modifies content in Contentful Entry which is then triggered by Contentful Webhook
Webhook then notifies with payload to Mulesoft
Mulesoft transforms Contentful payload to SAP Commerce payload
Mulesoft requests SAP Commerce Platform Webservices with payload as body to insert category or product
SAP Commerce Platform Webservices then persists data in SAP Commerce platform and in response status code is sent to Contentful Webhook Passing though Mulesoft.
There are some steps to prepare systems before integration:
Create a Contentful CMS account and then a "space" inside your account
Create "content model" and add "fields" in that model which is a sort of Database table and columns
Create some "content entries" in that model which can be supposed as Table Row
Let's suppose there are 3 fields in a content model which should look like the image below
2. SAP Commerce
Create catalog and catalog versions which would contain category and products
Add platformwebservices extension in localextensions.xml
ant clean all and verify if platformwebservices extension working
Create an application project in mulesoft
Create a flow and chain defined connectors
This will behave as entry point of the flow and will be used to receive payload from Contentful webhook
This will be used to request and receive full payload for particular category including its supercategories
This will be used to transform Contentful payload to SAP Commerce payload
This will be Used to Send data to SAP Commerce
1. Configure Settings in Contentful Application for Integration
Create Webhook in Contentful Application and go to Settings → Webhooks
Configure settings as defined in images below
URL field should be cloud hub URL where Mulesoft Application is deployed before /category
As defined in image, this webhook is configured for the entry of Category content type
Now when any record is inserted in Category model at the same time this Webhook would be triggered and data of that entry would be sent to Mulesoft
2. Configure Settings in Mule Application for Integration
Now we'll configure connectors in Mulesoft Application which were created in "Prepare Systems" section
Once done with the steps defined above, Add any category in Contentful then Publish it, and go to SAP Commerce Backoffice to verify the category.
As this integration works perfectly fine for products and categories, using mulesoft was an idea to not make any basic customisations in SAP Commerce however it can be achieved using Contentful API libraries like CMA and CDA by customising SAP Commerce Service layers and CronJobs. This Integration can be enhanced to make it work for assets integration for which there might be some customisation required in SAP Commerce to import external media.