SAP Hybris Commerce Best Practices
Comprehensive development guidelines and best practices for SAP Commerce Cloud (formerly Hybris).
This skill covers the complete development lifecycle from data modeling to frontend and backoffice configuration.
Version Context
- SAP Commerce Cloud: 2211+ (September 2025 update)
- JDK: 21
- Spring Framework: 6.2
- Architecture: Service Layer (Jalo layer deprecated)
Quick Reference
Core Concepts
- Extension-based architecture: modular design with custom extensions
- Type System: metadata-driven data model defined in items.xml
- Service Layer: primary API for business logic (ModelService, FlexibleSearchService)
- ImpEx: CSV-based data import/export tool
- Spring Integration: DI, AOP, and bean management
Development Workflow
- Define data model in
*-items.xml
- Run
ant clean all to generate model classes
- Perform system update to apply schema changes
- Implement services with Spring DI
- Create facades with DTOs for frontend
- Build controllers for web/REST APIs
- Create JSP views or use headless APIs
- Configure Solr for search functionality
- Write automated tests (unit + integration)
Topics
Backend Development
Frontend Development
Search & Indexing
Background Processing
Backoffice
Common Patterns
Service + Facade Pattern
// Service (backend logic)
public interface ProductService {
ProductModel findByCode(String code);
}
@Service
public class DefaultProductService implements ProductService {
private final FlexibleSearchService flexibleSearchService;
public DefaultProductService(final FlexibleSearchService flexibleSearchService) {
this.flexibleSearchService = flexibleSearchService;
}
@Override
public ProductModel findByCode(final String code) {
// ...
return null;
}
}
// Facade (frontend API)
public interface ProductFacade {
ProductData getProduct(String code);
}
@Service
public class DefaultProductFacade implements ProductFacade {
private final ProductService productService;
private final Converter<ProductModel, ProductData> converter;
public DefaultProductFacade(final ProductService productService,
final Converter<ProductModel, ProductData> converter) {
this.productService = productService;
this.converter = converter;
}
@Override
public ProductData getProduct(final String code) {
return converter.convert(productService.findByCode(code));
}
}
Model Lifecycle
Create -> InitDefaults -> Prepare -> Validate -> Save
Load -> LoadInterceptor
Delete -> RemoveInterceptor
Extension Dependencies
core -> facades -> storefront
-> backoffice
-> occ (REST API)
Best Practices Summary
DO
- Use Service Layer APIs (ModelService, FlexibleSearchService)
- Follow interface + implementation pattern
- Prefer constructor injection (Spring 6)
- Externalize configuration to properties files
- Write unit and integration tests
- Use facades with DTOs for frontend
- Validate input with interceptors or the validation framework
- Use ImpEx for data management
- Configure Solr for search functionality
- Follow SOLID principles
DON'T
- Use Jalo layer directly (deprecated)
- Use field injection (
@Autowired on fields)
- Hardcode configuration values
- Expose models directly to frontend
- Modify generated model classes
- Skip system update after items.xml changes
- Perform heavy operations in interceptors
- Use embedded Solr in production
Quick Commands
# Build and generate models
ant clean all
# Run tests
ant alltests
ant unittests
ant integrationtests
# Solr management
ant startSolrServer
ant stopSolrServer
# Initialize/update system
ant initialize
ant updatesystem
Resources
- SAP Help Portal (requires authentication)
- SAP Community (forums and blogs)
- Local HAC:
http://localhost:9001/hac
Note: this skill is based on SAP Commerce Cloud 2211+ (September 2025). For earlier versions, some features and APIs may differ.
1---2name: sap-hybris-commerce-best-practices3description: When users ask about SAP Commerce Cloud (Hybris) best practices, provide actionable guidance, checklists, and examples.4---56# SAP Hybris Commerce Best Practices78Comprehensive development guidelines and best practices for SAP Commerce Cloud (formerly Hybris).9This skill covers the complete development lifecycle from data modeling to frontend and backoffice configuration.1011## Version Context1213- **SAP Commerce Cloud**: 2211+ (September 2025 update)14- **JDK**: 2115- **Spring Framework**: 6.216- **Architecture**: Service Layer (Jalo layer deprecated)1718## Quick Reference1920### Core Concepts2122- **Extension-based architecture**: modular design with custom extensions23- **Type System**: metadata-driven data model defined in items.xml24- **Service Layer**: primary API for business logic (ModelService, FlexibleSearchService)25- **ImpEx**: CSV-based data import/export tool26- **Spring Integration**: DI, AOP, and bean management2728### Development Workflow29301. Define data model in `*-items.xml`312. Run `ant clean all` to generate model classes323. Perform system update to apply schema changes334. Implement services with Spring DI345. Create facades with DTOs for frontend356. Build controllers for web/REST APIs367. Create JSP views or use headless APIs378. Configure Solr for search functionality389. Write automated tests (unit + integration)3940## Topics4142### Backend Development4344- [Code Conventions](./references/00-code-conventions.md) - SAP Commerce coding style and formatting rules45- [Java Development Guidelines](./references/01-java-guidelines.md) - Coding standards, Spring patterns, service layer46- [Create Extensions](./references/02-extensions.md) - Extension structure, types, and configuration47- [Define Data Types](./references/03-data-types.md) - items.xml structure, types, relations48- [Using ImpEx](./references/04-impex.md) - Data import/export syntax and patterns49- [Dynamic Attributes](./references/05-dynamic-attributes.md) - Computed attributes without DB storage50- [Services](./references/06-services.md) - Business logic implementation with Spring51- [Properties Configuration](./references/07-properties.md) - Externalize configuration52- [Events](./references/08-events.md) - Event-driven architecture patterns53- [Interceptors](./references/09-interceptors.md) - Model lifecycle hooks54- [Validation Framework](./references/10-validation.md) - Declarative validation constraints55- [Automated Testing](./references/11-testing.md) - Unit and integration testing56- [Code Quality](./references/12-code-quality.md) - SOLID principles, extensibility, upgradability5758### Frontend Development5960- [Facades](./references/13-facades.md) - Facade pattern, DTOs, converters61- [Controllers](./references/14-controllers.md) - Spring MVC and REST controllers62- [WCMS Components](./references/15-wcms-components.md) - CMS content management63- [JSP Tags](./references/16-jsp-tags.md) - Custom tag libraries64- [JSP Views](./references/17-jsp-views.md) - View templates with JSTL6566### Search & Indexing6768- [Solr Integration](./references/18-solr.md) - Search configuration, indexing, facets6970### Background Processing7172- [Tasks and CronJobs](./references/19-tasks-and-cronjobs.md) - Background task scheduling and execution7374### Backoffice7576- [Backoffice Configuration](./references/20-backoffice-configuration.md) - cockpitng/backoffice config patterns (editor area, list view, search, wizards)7778## Common Patterns7980### Service + Facade Pattern8182```java83// Service (backend logic)84public interface ProductService {85 ProductModel findByCode(String code);86}8788@Service89public class DefaultProductService implements ProductService {9091 private final FlexibleSearchService flexibleSearchService;9293 public DefaultProductService(final FlexibleSearchService flexibleSearchService) {94 this.flexibleSearchService = flexibleSearchService;95 }9697 @Override98 public ProductModel findByCode(final String code) {99 // ...100 return null;101 }102}103104// Facade (frontend API)105public interface ProductFacade {106 ProductData getProduct(String code);107}108109@Service110public class DefaultProductFacade implements ProductFacade {111112 private final ProductService productService;113 private final Converter<ProductModel, ProductData> converter;114115 public DefaultProductFacade(final ProductService productService,116 final Converter<ProductModel, ProductData> converter) {117 this.productService = productService;118 this.converter = converter;119 }120121 @Override122 public ProductData getProduct(final String code) {123 return converter.convert(productService.findByCode(code));124 }125}126```127128### Model Lifecycle129130```131Create -> InitDefaults -> Prepare -> Validate -> Save132Load -> LoadInterceptor133Delete -> RemoveInterceptor134```135136### Extension Dependencies137138```139core -> facades -> storefront140 -> backoffice141 -> occ (REST API)142```143144## Best Practices Summary145146### DO147148- Use Service Layer APIs (ModelService, FlexibleSearchService)149- Follow interface + implementation pattern150- Prefer constructor injection (Spring 6)151- Externalize configuration to properties files152- Write unit and integration tests153- Use facades with DTOs for frontend154- Validate input with interceptors or the validation framework155- Use ImpEx for data management156- Configure Solr for search functionality157- Follow SOLID principles158159### DON'T160161- Use Jalo layer directly (deprecated)162- Use field injection (`@Autowired` on fields)163- Hardcode configuration values164- Expose models directly to frontend165- Modify generated model classes166- Skip system update after items.xml changes167- Perform heavy operations in interceptors168- Use embedded Solr in production169170## Quick Commands171172```bash173# Build and generate models174ant clean all175176# Run tests177ant alltests178ant unittests179ant integrationtests180181# Solr management182ant startSolrServer183ant stopSolrServer184185# Initialize/update system186ant initialize187ant updatesystem188```189190## Resources191192- SAP Help Portal (requires authentication)193- SAP Community (forums and blogs)194- Local HAC: `http://localhost:9001/hac`195196---197198Note: this skill is based on SAP Commerce Cloud 2211+ (September 2025). For earlier versions, some features and APIs may differ.