Update Data Templates not working in Sitecore Commerce

In my current Sitecore Commerce project we got an issue where the updates of templates in Storefront from Commerce Engine stopped working. There were no errors in logs and when we run the operation it finishes successfully but did not get the latest updates from Commerce Engine to Sitecore.

To give you more context we have a custom component added to Sellable Item commerce entity.

We double checked few things:
- Sellable Item entity is getting saved properly in Sitecore Commerce databases with custom components data.

- In Business app custom component data add/edit working properly.

All of the above was working properly. Then we decided to find out the API call that Sitecore uses to perform Update Data Templates operation. Sitecore has implemented a custom Data Provider named “CatalogDataProvider” to achieve integration between Sitecore and Commerce Engine. Catalog data provider has lots of API calls those are handled by the “Sitecore.Commerce.Plugin.Catalog” at Sitecore Commerce engine side.
To get the Sellable Item information Catalog data provider uses the “GetSellableItemConnect” API call. We tried this call in Postman and found that our custom components were there is the response but without the information we stored with them.

You can see that component Id in response is same as component id we checked in the json stored in database. So something was happening at serialization time where the data from the database is lost while sending the response.
By looking at our component classe again we found that we missed the “public” access modifier with our component class and that was the reason that Commerce Engine was not able to serialize custom implementation and only adding the base component class details in response.

And here is the updated response from API

Always make your custom components classes as “public” in Commerce engine.