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