SAP Spartacus 自定义 PageResolver 的用法

简介: 前置阅读:Angular路由里的resolve接口的使用方法有网友遇到一个问题:How to add my custom page resolver instead of Spartacus page resolver?

’m adding my resolver (which extended from PageMetaResolver) into providers in my own home.module. However, my method ‘resolve’ is not called. Have you got any ideas?

image.png

分析

The most specific Page Meta Resolver wins

Guessing from the name of your meta resolver, you want to provide custom meta only for your Home page. Please note that the most specific meta resolver wins thanks to the simple scoring algorithm, which takes into consideration 2 factors: page type and page template (see source https://github.com/SAP/cloud-commerce-spartacus-storefront/blob/develop/projects/core/src/cms/page/page-meta.resolver.ts#L11).


Currently your resolver HomePageMetaResolver has the same specificity as the generic one so your resolve method is not called.

specificity of all Page Meta Resolvers

You need to specify more your meta resolver by defining its property this.pageTemplate = ‘’. Then your HomePageMetaResolver will get higher score than a default ContentPageMetaResolver whenever you visit a homepage.


Custom scoring algorithms

For custom scoring algorithms (which could take pageId into account, for instance), you can overwrite the method getScore of your PageMetaResolvers. You can even extend the method PageMetaService.getMetaResolver to redefine all rules of chosing the right page meta resolver. But for your case the standard solution (described above) should suffice.

相关文章
|
4月前
|
搜索推荐 BI 开发者
sap.ui.comp.smarttable.SmartTable 组件 beforeRebindTable 事件的用法
sap.ui.comp.smarttable.SmartTable 组件 beforeRebindTable 事件的用法
|
11月前
|
缓存 负载均衡 前端开发
SAP Spartacus 和 Sticky session 相关的话题
SAP Spartacus 和 Sticky session 相关的话题
|
4月前
|
JSON 开发者 数据格式
关于 SAP Spartacus LandingPage2Template 区域的 layout 设计实现
关于 SAP Spartacus LandingPage2Template 区域的 layout 设计实现
|
4月前
|
搜索推荐 开发者 UED
关于 SAP Spartacus 层的 UI 设计
关于 SAP Spartacus 层的 UI 设计
|
4月前
|
开发者 UED
SAP Spartacus BREAKPOINT 枚举类型在 Spartacus layout 实现中的作用
SAP Spartacus BREAKPOINT 枚举类型在 Spartacus layout 实现中的作用
|
11月前
|
JavaScript 容器
关于 SAP Spartacus generic-link component 的模板代码
关于 SAP Spartacus generic-link component 的模板代码
|
11月前
|
Shell 容器
SAP UI5 的 Unified Shell 发展历史和用法介绍试读版
SAP UI5 的 Unified Shell 发展历史和用法介绍试读版
SAP UI5 的 Unified Shell 发展历史和用法介绍试读版
|
11月前
|
数据处理
SAP ABAP 里 FILTER 关键字的用法举例
SAP ABAP 里 FILTER 关键字的用法举例
|
11月前
|
SQL 数据库
SAP CDS view 里 UNION 操作的用法
SAP CDS view 里 UNION 操作的用法
|
11月前
|
SQL 数据建模 Serverless
SAP CDS view 的 having Condition 用法
SAP CDS view 的 having Condition 用法