sap-commerce-cloud

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SAP Commerce Development

SAP Commerce开发

Overview

概述

SAP Commerce Cloud (formerly Hybris) is an enterprise e-commerce platform built on Java and Spring. This skill provides guidance for extension development, type system modeling, service layer implementation, data management, API customization, accelerator patterns, Composable Storefront (Spartacus/Angular) integration, CCv2 cloud deployment, SAP BTP/Kyma integration, SmartEdit customization, and testing patterns for both Cloud (CCv2) and On-Premise deployments.
Modern Storefront Note: The JSP-based Accelerator storefront (Spring Web Flow, JSP/JSTL) is the legacy approach. The modern recommended storefront is Composable Storefront (formerly Spartacus) — an Angular/TypeScript Single Page Application that communicates with the backend exclusively via OCC REST APIs. New projects should use Composable Storefront. See composable-storefront.md.
SAP Commerce Cloud(原Hybris)是基于Java和Spring构建的企业级电商平台。本技能为Cloud(CCv2)和On-Premise部署场景提供扩展开发、类型系统建模、服务层实现、数据管理、API定制、加速器模式、Composable Storefront(Spartacus/Angular)集成、CCv2云部署、SAP BTP/Kyma集成、SmartEdit定制以及测试模式的相关指导。
现代前端说明:基于JSP的Accelerator前端(Spring Web Flow、JSP/JSTL)属于传统方案。当前推荐的现代前端是Composable Storefront(原Spartacus)——一款Angular/TypeScript单页应用,仅通过OCC REST API与后端通信。新项目应采用Composable Storefront。请参阅composable-storefront.md。

Core Architecture

核心架构

Type System

类型系统

Data modeling via
items.xml
defines item types, attributes, relations, and enumerations. Types are compiled into Java classes during build. See type-system.md for syntax and patterns.
通过
items.xml
进行数据建模,定义项目类型、属性、关联关系和枚举类型。类型会在构建过程中编译为Java类。语法和模式请参阅type-system.md。

Extensions

扩展

Modular architecture where functionality lives in extensions. Each extension has
extensioninfo.xml
for metadata,
items.xml
for types, and
*-spring.xml
for beans. See extension-development.md.
采用模块化架构,功能以扩展形式存在。每个扩展包含用于元数据的
extensioninfo.xml
、用于类型定义的
items.xml
以及用于Bean配置的
*-spring.xml
。请参阅extension-development.md。

Service Layer

服务层

Four-layer architecture: Facade (API for controllers) → Service (business logic) → DAO (data access) → Model (generated from types). See service-layer-architecture.md.
四层架构:Facade(控制器的API层)→ Service(业务逻辑层)→ DAO(数据访问层)→ Model(由类型生成)。请参阅service-layer-architecture.md。

Data Management

数据管理

ImpEx: Scripting language for data import/export. See impex-guide.md. FlexibleSearch: SQL-like query language for items. See flexiblesearch-reference.md.
ImpEx:用于数据导入/导出的脚本语言。请参阅impex-guide.md。 FlexibleSearch:面向项目的类SQL查询语言。请参阅flexiblesearch-reference.md。

OCC API

OCC API

RESTful web services exposing commerce functionality. Controllers use
DataMapper
for DTO conversion. See occ-api-development.md.
暴露电商功能的RESTful Web服务。控制器使用
DataMapper
进行DTO转换。请参阅occ-api-development.md。

Accelerators (Legacy JSP Storefront)

Accelerators(传统JSP前端)

Pre-built JSP/Spring MVC storefronts: B2C (retail) and B2B (enterprise with approval workflows). Legacy approach — new projects should use Composable Storefront or a headless approach. See accelerator-customization.md.
预构建的JSP/Spring MVC前端:B2C(零售)和B2B(带审批流程的企业级)。属于传统方案——新项目应采用Composable Storefront或无头架构。请参阅accelerator-customization.md。

Composable Storefront (Spartacus)

Composable Storefront(Spartacus)

Angular/TypeScript SPA that replaces JSP accelerators. Communicates exclusively via OCC APIs. Supports PWA, SSR, and feature libraries for B2C/B2B. See composable-storefront.md.
替代JSP加速器的Angular/TypeScript单页应用,仅通过OCC API通信。支持PWA、SSR以及面向B2C/B2B的功能库。请参阅composable-storefront.md。

Headless Commerce

无头电商

SAP Commerce Cloud as a headless backend — OCC APIs consumed by any frontend (React, Vue, mobile apps, etc.). The backend serves product, catalog, cart, order, and user data via REST. Composable Storefront is SAP's reference headless frontend, but custom frontends are supported.
SAP Commerce Cloud作为无头后端——OCC API可被任意前端(React、Vue、移动应用等)调用。后端通过REST提供商品、目录、购物车、订单和用户数据。Composable Storefront是SAP官方的参考无头前端,但也支持自定义前端。

CCv2 Cloud Deployment

CCv2云部署

SAP Commerce Cloud v2 (CCv2) is the managed cloud offering. Deployment is driven by
manifest.json
defining extensions, aspects (storefront/api/backoffice), and properties. See ccv2-deployment.md.
SAP Commerce Cloud v2(CCv2)是托管式云服务。部署由
manifest.json
驱动,该文件定义了扩展、组件(storefront/api/backoffice)和属性。请参阅ccv2-deployment.md。

SAP BTP Integration

SAP BTP集成

SAP Business Technology Platform integration via API Registry module and SAP BTP Extensions Integration Module (Kyma runtime). Allows microservices/serverless functions to react to Commerce events. See sap-btp-integration.md.
通过API Registry模块和SAP BTP Extensions Integration Module(Kyma运行时)实现SAP Business Technology Platform集成。允许微服务/无服务器函数响应Commerce事件。请参阅sap-btp-integration.md。

CronJobs & Task Engine

CronJobs & 任务引擎

Scheduled and asynchronous job execution. Define
AbstractJobPerformable
implementations, configure via
ServicelayerJob
+
CronJob
+
Trigger
in ImpEx. See cronjob-task-engine.md.
定时和异步任务执行。定义
AbstractJobPerformable
实现,通过ImpEx配置
ServicelayerJob
+
CronJob
+
Trigger
。请参阅cronjob-task-engine.md。

Business Processes

业务流程

Stateful workflows for order processing, returns, approvals, and custom flows. XML process definitions with action beans (
AbstractSimpleDecisionAction
,
AbstractAction
), wait states, and event triggers. See business-process.md.
用于订单处理、退货、审批和自定义流程的有状态工作流。包含动作Bean(
AbstractSimpleDecisionAction
、
AbstractAction
)、等待状态和事件触发器的XML流程定义。请参阅business-process.md。

Solr Search

Solr搜索

Product search and faceted navigation powered by Apache Solr. Configure indexed types, properties, value providers, and boost rules. See solr-search-configuration.md.
基于Apache Solr的商品搜索和分面导航。配置索引类型、属性、值提供器和权重规则。请参阅solr-search-configuration.md。

Promotions & Rule Engine

促销活动 & 规则引擎

Drools-based promotion rules with conditions and actions. Supports order/product/customer promotions, coupons, and custom actions. See promotions-rule-engine.md.
基于Drools的促销规则,包含条件和动作。支持订单/商品/客户促销、优惠券和自定义动作。请参阅promotions-rule-engine.md。

Caching

缓存

Multi-layered caching: platform region caches (entity, query, typesystem), Spring
@Cacheable
, and cluster-aware invalidation. See caching-guide.md.
多层缓存:平台区域缓存(实体、查询、类型系统)、Spring
@Cacheable
以及集群感知失效机制。请参阅caching-guide.md。

Backoffice

Backoffice

Administration UI customization via cockpitng: widget configuration, custom editors, search/list views, wizards, and deep links. See backoffice-configuration.md.
通过cockpitng定制管理UI:组件配置、自定义编辑器、搜索/列表视图、向导和深度链接。请参阅backoffice-configuration.md。

Common Workflows

常见工作流

Create a Custom Extension

创建自定义扩展

  1. Generate structure with
    ant extgen
    or use template from
    assets/extension-structure/
  2. Configure
    extensioninfo.xml
    with dependencies
  3. Define types in
    items.xml
  4. Configure beans in
    *-spring.xml
  5. Add to
    localextensions.xml
  6. Build:
    ant clean all
Reference: extension-development.md | Template:
assets/extension-structure/
  1. 使用
    ant extgen
    生成结构,或使用
    assets/extension-structure/
    中的模板
  2. 在
    extensioninfo.xml
    中配置依赖
  3. 在
    items.xml
    中定义类型
  4. 在
    *-spring.xml
    中配置Bean
  5. 添加到
    localextensions.xml
  6. 构建:
    ant clean all
参考:extension-development.md | 模板:
assets/extension-structure/

Define Custom Item Types

定义自定义项目类型

  1. Create or modify
    *-items.xml
    in extension
  2. Define itemtype with attributes, relations
  3. Build to generate model classes
  4. Use in services/DAOs
Reference: type-system.md | Templates:
assets/item-type-definition/
  1. 在扩展中创建或修改
    *-items.xml
  2. 定义包含属性、关联关系的itemtype
  3. 构建以生成模型类
  4. 在服务/DAO中使用
参考:type-system.md | 模板:
assets/item-type-definition/

Implement Service Layer

实现服务层

  1. Create DTO class for data transfer
  2. Create DAO interface and implementation with FlexibleSearch
  3. Create Service interface and implementation with business logic
  4. Create Facade interface and implementation for external API
  5. Configure beans in
    *-spring.xml
Reference: service-layer-architecture.md | Templates:
assets/service-layer/
  1. 创建用于数据传输的DTO类
  2. 创建带FlexibleSearch的DAO接口和实现
  3. 创建带业务逻辑的Service接口和实现
  4. 创建用于外部API的Facade接口和实现
  5. 在
    *-spring.xml
    中配置Bean
参考:service-layer-architecture.md | 模板:
assets/service-layer/

Import Data with ImpEx

使用ImpEx导入数据

  1. Create
    .impex
    file with header and data rows
  2. Use INSERT_UPDATE for create/modify operations
  3. Define macros for reusable values
  4. Import via HAC or
    ant importImpex
Reference: impex-guide.md | Templates:
assets/impex-scripts/
  1. 创建包含表头和数据行的
    .impex
    文件
  2. 使用INSERT_UPDATE进行创建/修改操作
  3. 定义可重用值的宏
  4. 通过HAC或
    ant importImpex
    导入
参考:impex-guide.md | 模板:
assets/impex-scripts/

Query with FlexibleSearch

使用FlexibleSearch查询

sql
SELECT {pk} FROM {Product} WHERE {code} = ?code
SELECT {p.pk} FROM {Product AS p JOIN Category AS c ON {p.supercategories} = {c.pk}} WHERE {c.code} = ?category
Reference: flexiblesearch-reference.md | Examples:
assets/flexiblesearch-queries/
sql
SELECT {pk} FROM {Product} WHERE {code} = ?code
SELECT {p.pk} FROM {Product AS p JOIN Category AS c ON {p.supercategories} = {c.pk}} WHERE {c.code} = ?category
参考:flexiblesearch-reference.md | 示例:
assets/flexiblesearch-queries/

Customize OCC API

定制OCC API

  1. Create controller with
    @Controller
    and
    @RequestMapping
  2. Create WsDTO for response data
  3. Create populator for model-to-DTO conversion
  4. Register in
    *-web-spring.xml
Reference: occ-api-development.md | Templates:
assets/occ-customization/
  1. 创建带
    @Controller
    和
    @RequestMapping
    的控制器
  2. 创建用于响应数据的WsDTO
  3. 创建用于模型转DTO的populator
  4. 在
    *-web-spring.xml
    中注册
参考:occ-api-development.md | 模板:
assets/occ-customization/

Extend Accelerator Checkout

扩展Accelerator结账流程

  1. Create custom checkout step implementing
    CheckoutStep
  2. Configure in checkout flow XML
  3. Create JSP for step UI
  4. Register beans in
    *-spring.xml
Reference: accelerator-customization.md | Templates:
assets/checkout-customization/
  1. 创建实现
    CheckoutStep
    的自定义结账步骤
  2. 在结账流程XML中配置
  3. 为步骤UI创建JSP
  4. 在
    *-spring.xml
    中注册Bean
参考:accelerator-customization.md | 模板:
assets/checkout-customization/

Create a Scheduled Job (CronJob)

创建定时任务(CronJob)

  1. Implement
    AbstractJobPerformable<CronJobModel>
    with
    perform()
    method
  2. Register Spring bean with
    parent="abstractJobPerformable"
  3. Create
    ServicelayerJob
    ,
    CronJob
    , and
    Trigger
    via ImpEx
  4. Test via HAC > Platform > CronJobs
Reference: cronjob-task-engine.md | Templates:
assets/cronjob/
  1. 实现带
    perform()
    方法的
    AbstractJobPerformable<CronJobModel>
  2. 注册继承
    parent="abstractJobPerformable"
    的Spring Bean
  3. 通过ImpEx创建
    ServicelayerJob
    、
    CronJob
    和
    Trigger
  4. 通过HAC > Platform > CronJobs测试
参考:cronjob-task-engine.md | 模板:
assets/cronjob/

Define a Business Process

定义业务流程

  1. Create process definition XML in
    resources/processes/
  2. Implement action beans extending
    AbstractSimpleDecisionAction
  3. Register action beans in Spring with
    parent="abstractAction"
  4. Register process definition via
    ProcessDefinitionResource
    Spring bean
  5. Start process via
    BusinessProcessService.createProcess()
    and
    startProcess()
Reference: business-process.md | Templates:
assets/business-process/
  1. 在
    resources/processes/
    中创建流程定义XML
  2. 实现继承
    AbstractSimpleDecisionAction
    的动作Bean
  3. 注册继承
    parent="abstractAction"
    的动作Bean到Spring
  4. 通过
    ProcessDefinitionResource
    Spring Bean注册流程定义
  5. 通过
    BusinessProcessService.createProcess()
    和
    startProcess()
    启动流程
参考:business-process.md | 模板:
assets/business-process/

Configure Solr Product Search

配置Solr商品搜索

  1. Set up
    SolrFacetSearchConfig
    with server, languages, currencies, catalog versions
  2. Define
    SolrIndexedType
    for Product
  3. Configure
    SolrIndexedProperty
    entries (searchable, facet, sortable)
  4. Set up indexer CronJobs (full nightly, incremental every 5 min)
  5. Test search via HAC > Platform > Solr
Reference: solr-search-configuration.md | Templates:
assets/solr-configuration/
  1. 设置包含服务器、语言、货币、目录版本的
    SolrFacetSearchConfig
  2. 为Product定义
    SolrIndexedType
  3. 配置
    SolrIndexedProperty
    条目(可搜索、分面、可排序)
  4. 设置索引器CronJobs(夜间全量索引,每5分钟增量索引)
  5. 通过HAC > Platform > Solr测试搜索
参考:solr-search-configuration.md | 模板:
assets/solr-configuration/

Set Up Promotions

设置促销活动

  1. Create
    PromotionGroup
    for your store
  2. Define
    PromotionSourceRule
    with conditions and actions
  3. Configure coupons (
    SingleCodeCoupon
    /
    MultiCodeCoupon
    ) if needed
  4. Publish rules to activate them
  5. Test in Backoffice > Marketing > Promotion Rules
Reference: promotions-rule-engine.md | Templates:
assets/promotions/
  1. 为店铺创建
    PromotionGroup
  2. 定义包含条件和动作的
    PromotionSourceRule
  3. 按需配置优惠券(
    SingleCodeCoupon
    /
    MultiCodeCoupon
    )
  4. 发布规则以激活
  5. 在Backoffice > Marketing > Promotion Rules中测试
参考:promotions-rule-engine.md | 模板:
assets/promotions/

Integrate Composable Storefront (Spartacus)

集成Composable Storefront(Spartacus)

  1. Set up OCC endpoints and CORS on the Commerce backend
  2. Scaffold Angular app:
    ng add @spartacus/schematics@latest --base-url <OCC_URL> --base-site=<SITE_ID> --ssr
  3. Configure
    SpartacusConfigurationModule
    with
    provideConfig
  4. Customize CMS components via
    cmsComponents
    mapping in
    provideConfig
  5. Override services by providing custom service classes in feature modules
Reference: composable-storefront.md | Templates:
assets/composable-storefront/
  1. 在Commerce后端设置OCC端点和CORS
  2. 搭建Angular应用:
    ng add @spartacus/schematics@latest --base-url <OCC_URL> --base-site=<SITE_ID> --ssr
  3. 使用
    provideConfig
    配置
    SpartacusConfigurationModule
  4. 通过
    provideConfig
    中的
    cmsComponents
    映射定制CMS组件
  5. 在功能模块中提供自定义服务类以覆盖原有服务
参考:composable-storefront.md | 模板:
assets/composable-storefront/

Deploy to CCv2

部署到CCv2

  1. Configure
    manifest.json
    at repository root with
    commerceSuiteVersion
    ,
    extensions
    ,
    aspects
  2. Set environment properties in CCv2 Cloud Portal or property files
  3. Push to connected repository to trigger build
  4. Promote build through environments (dev → staging → production)
Reference: ccv2-deployment.md
  1. 在仓库根目录配置
    manifest.json
    ,包含
    commerceSuiteVersion
    、
    extensions
    、
    aspects
  2. 在CCv2云门户或属性文件中设置环境属性
  3. 推送至关联仓库触发构建
  4. 在环境间推广构建版本(开发 → 预发布 → 生产)
参考:ccv2-deployment.md

Integrate SAP BTP / Kyma

集成SAP BTP / Kyma

  1. Configure API Registry module to expose Commerce APIs and events
  2. Connect Kyma runtime via SAP BTP Extensions Integration Module
  3. Implement microservices/lambdas to react to Commerce events
  4. Use API Registry for webhook-based outbound communication
Reference: sap-btp-integration.md
  1. 配置API Registry模块以暴露Commerce API和事件
  2. 通过SAP BTP Extensions Integration Module连接Kyma运行时
  3. 实现微服务/Lambda以响应Commerce事件
  4. 使用API Registry实现基于Webhook的出站通信
参考:sap-btp-integration.md

Write Tests for Custom Extension

为自定义扩展编写测试

  1. Annotate unit tests with
    @UnitTest
    , integration tests with
    @IntegrationTest
  2. Unit tests: use Mockito mocks, no Spring context, place in
    testsrc/
  3. Integration tests: extend
    ServicelayerTest
    or
    ServicelayerTransactionalTest
  4. OCC API integration tests: use REST Assured or MockMvc against a running OCC endpoint
  5. Load test data via
    importCsv("/myext/test/testdata.impex", "utf-8")
  6. Run locally:
    ant unittests -Dtestclasses.extensions=myextension
  7. Configure CCv2 test run in
    manifest.json
    under
    "tests"
Reference: testing-guide.md
  1. 单元测试标注
    @UnitTest
    ,集成测试标注
    @IntegrationTest
  2. 单元测试:使用Mockito模拟,无需Spring上下文,放置在
    testsrc/
  3. 集成测试:继承
    ServicelayerTest
    或
    ServicelayerTransactionalTest
  4. OCC API集成测试:针对运行中的OCC端点使用REST Assured或MockMvc
  5. 通过
    importCsv("/myext/test/testdata.impex", "utf-8")
    加载测试数据
  6. 本地运行:
    ant unittests -Dtestclasses.extensions=myextension
  7. 在
    manifest.json
    的
    "tests"
    下配置CCv2测试运行
参考:testing-guide.md

Quick Reference

快速参考

TaskReferenceAssetsScript
Extension setupextension-development.md
assets/extension-structure/
scripts/generate-extension.sh
Type definitionstype-system.md
assets/item-type-definition/
-
Service layerservice-layer-architecture.md
assets/service-layer/
-
Data importimpex-guide.md
assets/impex-scripts/
scripts/validate-impex.sh
Queriesflexiblesearch-reference.md
assets/flexiblesearch-queries/
scripts/query-items.sh
API customizationocc-api-development.md
assets/occ-customization/
-
Checkout/Storefront (legacy)accelerator-customization.md
assets/checkout-customization/
-
Composable Storefrontcomposable-storefront.md
assets/composable-storefront/
-
CCv2 deploymentccv2-deployment.md--
SAP BTP/Kymasap-btp-integration.md--
Testingtesting-guide.md--
Spring configspring-configuration.md--
Data patternsdata-modeling-patterns.md--
Troubleshootingtroubleshooting-guide.md--
CronJobscronjob-task-engine.md
assets/cronjob/
-
Business processesbusiness-process.md
assets/business-process/
-
Solr searchsolr-search-configuration.md
assets/solr-configuration/
-
Promotionspromotions-rule-engine.md
assets/promotions/
-
Cachingcaching-guide.md--
Backofficebackoffice-configuration.md--
任务参考文档资源脚本
扩展设置extension-development.md
assets/extension-structure/
scripts/generate-extension.sh
类型定义type-system.md
assets/item-type-definition/
-
服务层service-layer-architecture.md
assets/service-layer/
-
数据导入impex-guide.md
assets/impex-scripts/
scripts/validate-impex.sh
查询flexiblesearch-reference.md
assets/flexiblesearch-queries/
scripts/query-items.sh
API定制occ-api-development.md
assets/occ-customization/
-
结账/前端(传统)accelerator-customization.md
assets/checkout-customization/
-
Composable Storefrontcomposable-storefront.md
assets/composable-storefront/
-
CCv2部署ccv2-deployment.md--
SAP BTP/Kymasap-btp-integration.md--
测试testing-guide.md--
Spring配置spring-configuration.md--
数据模式data-modeling-patterns.md--
故障排除troubleshooting-guide.md--
CronJobscronjob-task-engine.md
assets/cronjob/
-
业务流程business-process.md
assets/business-process/
-
Solr搜索solr-search-configuration.md
assets/solr-configuration/
-
促销活动promotions-rule-engine.md
assets/promotions/
-
缓存caching-guide.md--
Backofficebackoffice-configuration.md--

Resources

资源

scripts/

scripts/

Utility scripts for common tasks:
  • generate-extension.sh
    - Scaffold new extension structure
  • validate-impex.sh
    - Validate ImpEx syntax before import
  • query-items.sh
    - Execute FlexibleSearch queries via HAC
用于常见任务的实用脚本:
  • generate-extension.sh
    - 生成新扩展结构
  • validate-impex.sh
    - 导入前验证ImpEx语法
  • query-items.sh
    - 通过HAC执行FlexibleSearch查询

references/

references/

Detailed guides for each topic area. Load as needed for in-depth information.
各主题领域的详细指南。按需加载以获取深入信息。

assets/

assets/

Production-quality code templates ready to copy and customize. Organized by domain (service-layer, impex-scripts, etc.).
可直接复制并定制的生产级代码模板。按领域(服务层、ImpEx脚本等)组织。