SAP Spartacus 自定义 PageResolver 的用法

’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?

SAP Spartacus 自定义 PageResolver 的用法

分析

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.

上一篇:尝新阿里云E-MapReduce MetaService服务


下一篇:如何在E-MapReduce上进行Kafka集群间数据复制