Existing but unused API in SAP Commerce for Store Finder

喜夏-厌秋 提交于 2021-02-11 12:29:08

问题


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:


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.

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.



来源:https://stackoverflow.com/questions/62319118/existing-but-unused-api-in-sap-commerce-for-store-finder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!