You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hybris 2211+Spartacus 6环境下SmartEdit内容插槽边框不显示

SmartEdit插槽边框不显示的配置排查方案

针对Hybris 2211 + Spartacus 6环境下SmartEdit编辑模式无插槽边框的问题,结合你提供的代码,以下是需要检查的配置遗漏点:

1. 替换配置占位符为实际值

你的SmartEditConfig中使用了占位符,必须替换为对应环境的真实值:

provideConfig(<SmartEditConfig>{
  smartEdit: {
    // 替换为Hybris后台的SmartEdit预览路由,通常是/cms/storefrontpreview
    storefrontPreviewRoute: '/cms/storefrontpreview',
    // 替换为SmartEdit的部署域名(包含端口),比如http://localhost:9002
    allowOrigin: 'http://localhost:9002',
  },
})

占位符未替换会导致SmartEdit无法正确识别店面的预览上下文,进而无法注入插槽边框。

2. 移除手动调用的processCmsPage

在Spartacus 6中,SmartEditModule会自动处理页面初始化逻辑,模块构造函数中手动调用this.smartEditService.processCmsPage()可能干扰正常流程,建议移除这部分代码:

// 移除以下构造函数代码
constructor(private smartEditService: SmartEditService) {
  this.smartEditService.processCmsPage();
}

3. 确保内容插槽使用官方CmsPageSlotComponent

SmartEdit仅能识别Spartacus官方的CmsPageSlotComponent来渲染编辑边框。检查你的店面模板,所有内容插槽是否都通过以下方式渲染:

<cx-page-slot position="[插槽位置ID]"></cx-page-slot>

若使用了自定义组件替代cx-page-slot,需要确保该组件集成了SmartEdit的插槽标记逻辑。

4. 检查Hybris后台配置

  • 在Backoffice中,确认当前站点已启用SmartEdit功能:进入WCMS > Website > 你的站点,检查SmartEdit Enabled是否勾选。
  • 确认操作用户拥有SmartEdit相关权限(如cmsmanager角色)。
  • 检查Storefront Preview URL配置是否与店面域名一致:进入WCMS > SmartEdit > Storefront Settings,确保预览URL指向你的Spartacus店面地址。

5. 验证跨域配置

SmartEdit与店面分属不同域名时,需确保:

  • Hybris后台的CORS配置允许店面域名的请求:在local.properties中添加类似配置:
    corsfilter.allowedOrigins=http://localhost:4200
    corsfilter.allowedMethods=GET,POST,PUT,DELETE,OPTIONS
    
  • Spartacus的allowOrigin配置与SmartEdit的域名完全匹配(包括协议、域名、端口)。

内容的提问来源于stack exchange,提问作者iamrooovic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 12:35:18