SAP Spartacus 允许我们覆盖 PDP 中使用的各种组件。示例:ProductSummaryComponent (cx-product-summary)。
使用 ConfigModule 覆盖它们非常简单,因为它们是 CMS 组件。
我的问题是关于我们如何使用控制器可能返回的附加属性。
示例 - 让我们考虑向 ProductModel 添加一个属性“manufacturedYear”,然后我们还通过 beans xml 将其包含在 ProductData 中。现在它在 Data 对象中,假设我们将它添加到 ProductWsDTO 并将它添加到 DTO 映射中,现在它将在 /product/{code} API 调用中返回。
在 UI 中,我们有以下产品:
product$: Observable = this.currentProductService.getProduct();
所以“产品”是@spartacus/core 中“product.model.ts”中可用的模型。我们如何扩展它,以便我们可以通过使用进行实际 API 调用的底层服务来使用新的“manufacturedYear”?
目的只是扩展模型,但使用底层服务进行 API 调用以获取我们的附加属性。
谢谢你的帮助