https://stackoverflow.com/que...spa
AFAIK, currently we do not have anything similar to CurrentProductService for current category.
当前 SAP Spartacus 标准实现里,缺少相似 CurrentProductService 对产品明细页面那样的支持。code
Looking at the implementation of CurrentProductService you can see that it is using RoutingService and it's getRouterState() method (picture 1).
研究 CurrentProductService 的实现代码,发现其实现原理是,首先利用 RoutingService,从 RouterState 中拿到当前页面的产品code,而后使用另外一个API,productService, 来读取产品的明细数据。orm
You can create something similar for current category, because the router state consists of category informations (as seen below on picture 2).
所以咱们能够采起相似的思路,从 category 页面的State里,提取出category明细信息:router
更多Jerry的原创文章,尽在:"汪子熙":rem