0

There are two API’s for SAP Commerce Store which are present in the Swagger API description but are not currently being used by the store finder page in Spartacus: • “/{baseSiteId}/stores/country/{countryIso}/region/{regionIso}”. • “/{baseSiteId}/stores/country/{countryIso}”

What is the best approach in Spartacus to add a new call for the following API: “/{baseSiteId}/stores/country/{countryIso}/region/{regionIso}”.

1 Answers1

3

The OCC API has many endpoints that aren't necessarily used in Spartacus. There are either multiple endpoints to achieve the same thing, or a feature hasn't been build /finalised in Spartacus.

There are various ways to invoke a new API. One approach that is both clean and following the Spartacus architecture, is to customise the StoreFinderService. The StoreFinderService is a facade that acts in between the (more complex) state management layer, see diagram below.

Spartacus data binding architecture

If you'd add a method in a custom version of this facade, you could use the httpClient directly in the service. That is often enough, however if you like/need to store the response in the store, you could introduce custom state, or even extend the connector and adapters. Generally speaking, this complexity is not needed in a project implementation.

tobi-or-not-tobi
  • 1,250
  • 1
  • 8
  • 10