Professional Documents
Culture Documents
FormationHybris Coretrail 11032021
FormationHybris Coretrail 11032021
21
20
/
03
/
11
SQLI
HYBRIS CORE
OVERVIEW
@SQLI
© SQLI2021
2013 2
Be
fo
re
yo
u
sta
rt
3
BEFORE YOU START
ONLINE RESOURCES
+ Hybris Wiki
+ Hybris Help
+ Hybris Expert
@SQLI
© SQLI2021
2013 4
BEFORE YOU START
RELEASES
+ Backward compatibility
+ Previous release is supported up to 24
months upon availability of newer (unless
yours SLA specifies different)
+ Easy upgrades
+ Numbering convention:
1905
Year. Month
@SQLI
© SQLI2021
2013 5
A
r
O c hi
ve te
rv ctu
ie re
w
6
ARCHITECTURE OVERVIEW
BASIC ARCHITECTURE
@SQLI
© SQLI2021
2013 7
ARCHITECTURE OVERVIEW
BASIC ARCHITECTURE
• Extension :
• Represents the technical structure of a module.
• Can contain business logic, type definitions, a web application, or other
@SQLI
© SQLI2021
2013 8
ARCHITECTURE OVERVIEW
BASIC ARCHITECTURE
@SQLI
© SQLI2021
2013 9
ARCHITECTURE OVERVIEW
LAYER ARCHITECTURE
SAP Hybris Commerce contains several layers, each of which has a different
function and data abstraction level.
@SQLI
© SQLI2021
2013 10
ARCHITECTURE OVERVIEW
MODES OF OPERATION
Single mode
@SQLI
© SQLI2021
2013 11
ARCHITECTURE OVERVIEW
MODES OF OPERATION
Cluster mode
@SQLI
© SQLI2021
2013 12
ARCHITECTURE OVERVIEW
MODES OF OPERATION
Tenant mode
@SQLI
© SQLI2021
2013 13
Ex
co te
n c nsi
e p on
t
EXTENSION CONCEPT
DEFINITION
Extension : project with its own data model and business logic.
Goal: keeping CUSTOM code separated from Hybris code, making the custom code easier to reuse
nd to migrate to future versions.
Always use your own extension to create, extend or overload existing hybris business logic
@SQLI
© SQLI2021
2013 15
EXTENSION CONCEPT
STRUCTURE OF AN EXTENSION
src , testsrc Contains the source code & junit tests files
web This directory contains the web extension
module parts of the extension (JSP files,
libraries).
.classpath Classpath file for Eclipse.
@SQLI
© SQLI2021
2013 16
EXTENSION CONCEPT
STRUCTURE OF AN EXTENSION
classes Contains all .class files for src, testsrc and gensrc
folders of the extension.
build.xml This build file calls the Platform build file for actual
action and provides the necessary parameters to it.
This way ant targets are consistent throughout the
entire installation.
extensioninfo.xsd Copied from <${HYBRIS_BIN_DIR}>
/platform/resources/schemas. Allows validating the
extensioninfo.xml file.
platformhome.properties Automatically generated file. It contains only the
relative path to <${HYBRIS_BIN_DIR}>/platform.
@SQLI
© SQLI2021
2013 Do not modify it. 18
EXTENSION CONCEPT
CONFIGURATION FILES
or global settings and to override any extension specific configuration always use the config folder,
local.properties
Overrides any properties specified in each extension project.properties file
Introduces global properties like database url and credentials
localextensions.xml
List of extensions used by build framework
Beside that: configuration templates for bundled servers, language packs, license,
@SQLI
© SQLI2021
2013 19
EXTENSION CONCEPT
BUILD FRAMEWORK
nt & Eclipse compiler to automatically run tasks such as code generation and copying, parsing, and
es.
AP Hybris Commerce as a whole consists of extensions of the Hybris Platform plus any other product
y referencing an extension in the localextensions.xml file, that extension is integrated into the SAP H
ommerce build framework.
Build Scope:
• platform-wide: Hybris Platform and all extensions
• extension-wide: Current extension only
@SQLI
© SQLI2021
2013 20
EXTENSION CONCEPT
BUILD TARGETS
@SQLI
© SQLI2021
2013 21
EXTENSION CONCEPT
AVAILABLE CONTEXTS
@SQLI
© SQLI2021
2013 22
EXTENSION CONCEPT
AVAILABLE CONTEXTS
@SQLI
© SQLI2021
2013 23
D
at
aM
od
el
DATA MODEL
P Hybris Commerce uses a system of types to organize data, for example product information, custom
resses, or orders.
@SQLI
© SQLI2021
2013 25
DATA MODEL
ITEMS AND TYPES
There are two major kinds of types: System-related types and business-related types.
System-related types:
• Infrastructure types: ComposedTypes (also referred to as ItemTypes)
• Data types: CollectionTypes, MapTypes, EnumerationTypes, and AtomicTypes.
@SQLI
© SQLI2021
2013 26
DATA MODEL
JAVA CLASSES VS HYBRIS TYPES
@SQLI
© SQLI2021
2013 27
DATA MODEL
TYPES AND ATTRIBUTES
@SQLI
© SQLI2021
2013 28
DATA MODEL
ATTRIBUTES OF A (COMPOSED) TYPE
@SQLI
© SQLI2021
2013 29
DATA MODEL
EXTENDING THE DATA MODEL
@SQLI
© SQLI2021
2013 30
DATA MODEL
EXTENDING
@SQLI
© SQLI2021
2013 31
DATA MODEL
ATTRIBUTES
@SQLI
© SQLI2021
2013 32
DATA MODEL
ENUMERATED TYPES
@SQLI
© SQLI2021
2013 33
DATA MODEL
COMPOSED TYPE REFERENCE
@SQLI
© SQLI2021
2013 34
DATA MODEL
RELATIONS
@SQLI
© SQLI2021
2013 35
DATA MODEL
TABLE STRUCTURE
@SQLI
© SQLI2021
2013 36
DATA MODEL
AUTOMATIC GENERATION
@SQLI
© SQLI2021
2013 37
DATA MODEL
INITIALIZE & UPDATE SYSTEM
System Initialization:
• Entire type system is created from scratch.
• ALL database tables are dropped.
• Data model is created from scratch as defined in the items.xml files.
• New tables with initial dataset are created
• Existing data model definitions will be lost!
System Update:
• Existing tables are updated to match changes in the domain model.
• No loss of data!
• Two major aspects:
Adding newly defined types to the type system definition in the database
Modifying type system definition in the database to match the definition in the domain mode
• By default, all items for subtypes are stored in the same database tables as their supertypes.
• Technically, the process of specifying into which database table the items of a type are stored is ca
deployment
@SQLI
© SQLI2021
2013 39
BUNDLED SERVER
WHAT IS THE HYBRIS SERVER
@SQLI
© SQLI2021
2013 40
BUNDLED SERVER
WHAT IS THE HYBRIS SERVER
Production-ready quality and best suited to run all applications of the hybris
Multichannel Suite
Easy installation
Contains a wrapper that automatically restarts the Apache Tomcat Java Virtual Machine
if the Apache Tomcat hangs or stops.
@SQLI
© SQLI2021
2013 41
Im
po
rt
Ex a nd
po
rt
IMPORT AND EXPORT
IMPEX
It’s an interface between CSV files and the hybris Multichannel Suite’s Type System
• you can “import” instances of types from CSV.
• you can “export” instances of types into CSV.
@SQLI
© SQLI2021
2013 43
IMPEX
TYPICAL FIELDS PF USE
• In live operation:
to import customer data into a production system
to synchronize data with other systems, such as an ERP or LDAP
to create backups
to update data at runtime
can be run from CronJobs
• In migrations:
to migrate data from one hybris installation to another
• In development:
to import sample data (e.g. on system initialization)
to import test data into testing system
@SQLI
© SQLI2021
2013 44
IMPEX
SYNTAX BASICS
@SQLI
© SQLI2021
2013 45
IMPEX
BASIC SYNTAX EXAMPLE
@SQLI
© SQLI2021
2013 46
IMPEX
SYNTAX ELEMENTS
@SQLI
© SQLI2021
2013 47
IMPEX
CATALOG EXAMPLE
@SQLI
© SQLI2021
2013 48
IMPEX
USING MACROS AND DEFAULTS
@SQLI
© SQLI2021
2013 49
IMPEX
MORE EXAMPLE
@SQLI
© SQLI2021
2013 50
IMPEX
SCRIPT FOR EXPORT
@SQLI
© SQLI2021
2013 51
IMPEX
WHERE IMPEX CAN BE EXECUTED
HMC: Create an
HAC
ImpExImportCronJob or
ImpExImportCronJob
ssential Data:
ecessary during initialization: Creates the Default catalog, restrictions, and basic CronJobs, for exam
roject Data:
xtension-specific project data
@SQLI
© SQLI2021
2013 53
Fl
ex
Se ib
ar le
ch
FLEXIBLE SEARCH
OVERVIEW
• SQL-like syntax
@SQLI
© SQLI2021
2013 55
FLEXIBLE SEARCH
SYNTAX
@SQLI
© SQLI2021
2013 56
FLEXIBLE SEARCH
QUERY EXAMPLES
@SQLI
© SQLI2021
2013 57
FLEXIBLE SEARCH
MORE QUERY EXAMPLES
@SQLI
© SQLI2021
2013 58
FLEXIBLE SEARCH
QUERYING WITH PARAMETERS
@SQLI
© SQLI2021
2013 59
Th
eS
er
la vi
ye ce
r
SERVICE LAYER
OVERVIEW
The Hybris ServiceLayer is an API for developing services for SAP Hybris Commerce.
t provides a number of common services, while allowing you to extend these or develop your own.
@SQLI
© SQLI2021
2013 62
SERVICE LAYER
STRUCTURE OVERVIEW
A client in this context is any software component that uses the ServiceLayer, such as:
• Page Controllers of an MVC framework
• Web Service clients
• Scripts
• Other services
@SQLI
© SQLI2021
2013 63
SERVICE LAYER
SERVICES
Services may use other services to perform their tasks but should keep their interdependencies to a
avoid overly tight coupling with other components
@SQLI
© SQLI2021
2013 64
SERVICE LAYER
STRATEGIES
A service may delegate parts of its tasks to smaller micro-services, called strategies.
Strategies help to further encapsulate behavior and make it more adaptable/usable.
@SQLI
© SQLI2021
2013 65
SERVICE LAYER
DAO & MODEL
@SQLI
© SQLI2021
2013 66
SERVICE LAYER
MODEL LIFE CYCLE
@SQLI
© SQLI2021
2013 67
SERVICE LAYER
HOOKS FOR INITIALIZATION AND
UPDATE PROCESS
ou may use the @SystemSetup annotation in any ServiceLayer class to hook ServiceLayer
to the Hybris initialization and update life-cycle events.
Spring Configuration of Java Class
The Java classes, in which the @SystemSetup annotation is used, must be registered as Spring beans
n the ApplicationContext:
Example:
@SQLI
© SQLI2021
2013 68
SERVICE LAYER
INTERCEPTORS OVERVIEW
There are various types of interceptors allowing you to interrupt the intended course of a Model’s l
With interceptors, you can modify a Model or raise exceptions to interrupt the current step
@SQLI
© SQLI2021
2013 69
SERVICE LAYER
INTERCEPTORS
@SQLI
© SQLI2021
2013 70
SERVICE LAYER
IMPLEMENTING INTERCEPTORS
The PrepareInterceptor is called before a model is saved to the database and before it i
by ValidateInterceptor
The ValidateInterceptor is called before a model is saved to the database and after it ha
prepared by the PrepareInterceptor
@SQLI
© SQLI2021
2013 71
SERVICE LAYER
REGISTERING AN INTERCEPTOR
@SQLI
© SQLI2021
2013 72
SERVICE LAYER
MAPPING THE INTERCEPTOR
@SQLI
© SQLI2021
2013 73
SERVICE LAYER
EVENTS
Event listeners are objects that are notified of events and perform business
corresponding to the event that occurred
@SQLI
© SQLI2021
2013 74
SERVICE LAYER
IMPLEMENTING THE EVENT SYSTEM
@SQLI
© SQLI2021
2013 75
SERVICE LAYER
IMPLEMENTATION – EVENT LISTENERS
@SQLI
© SQLI2021
2013 76
SERVICE LAYER
IMPLEMENTATION – EVENT LISTENERS
@SQLI
© SQLI2021
2013 77
SERVICE LAYER
IMPLEMENTATION – EVENT LISTENERS
@SQLI
© SQLI2021
2013 78
SERVICE LAYER
EVENTS
hat means that the current thread is locked until all listeners have reacted
an event. Therefore you should keep an eye on the performance of your list
d make sure that your code scales well.
@SQLI
© SQLI2021
2013 80
SERVICE LAYER
TRANSACTION-AWARE EVENTS
@SQLI
© SQLI2021
2013 81
SERVICE LAYER
PREDEFINED EVENTS – CLUSTERAWARE AND TRANSACTIONAWARE
EVENTS
@SQLI
© SQLI2021
2013 82
SERVICE LAYER
PREDEFINED EVENTS – NON-CLUSTER AWARE EVENTS
@SQLI
© SQLI2021
2013 83
SERVICE LAYER
JAVA BEANS
Java Beans are used as transport objects for the frontend layer
Contain an abstraction of models (subset of attributes from models)
Are automatically generated
Their class name, attributes or superclass are defined in xml configuration
Each extension may provide a bean configuration file
Definitions of these Java Beans or Enums are merged across extensions.
Java Beans Overview
@SQLI
© SQLI2021
2013 84
SERVICE LAYER
JAVA BEANS
@SQLI
© SQLI2021
2013 85
SERVICE LAYER
JAVA BEANS –TEMPLATE-
@SQLI
© SQLI2021
2013 86
Cr
on
Jo
bs
CRONJOBS
OVERVIEW
Automated tasks
Performed at a certain time (such as 16:05), or at
fixed intervals (such as every five minutes)
Can be used for:
Backups
Updating / synchronizing catalog contents
Imports / Exports
Re-calculating prices
etc…
@SQLI
© SQLI2021
2013 88
CRONJOBS
OVERVIEW
@SQLI
© SQLI2021
2013 89
CRONJOBS
HOW TO CREATE A CRONJOB
@SQLI
© SQLI2021
2013 90
CRONJOBS
HOW TO CREATE A CRONJOB
@SQLI
© SQLI2021
2013 91
CRONJOBS
HOW TO START A CRONJOB
@SQLI
© SQLI2021
2013 92
Ba
ck
of
f ic
e
BACKOFFICE
OVERVIEW
@SQLI
© SQLI2021
2013 95
BACKOFFICE
WIDGETS
@SQLI
© SQLI2021
2013 96
BACKOFFICE
EVENT COLLABORATION
@SQLI
© SQLI2021
2013 98
BACKOFFICE
WHAT CONSTITUTES A WIDGET?
@SQLI
© SQLI2021
2013 99
BACKOFFICE
EXAMPLE WIDGET DEFINITION: PRODUCT LIST
@SQLI
© SQLI2021
2013 100
BACKOFFICE
EXAMPLE WIDGET VIEW: PRODUCT LIST
@SQLI
© SQLI2021
2013 101
BACKOFFICE
EXAMPLE WIDGET CONTROLLER: PRODUCT LIST
@SQLI
© SQLI2021
2013 102
W
or
kf
lo
w
WORKFLOW
OVERVIEW
@SQLI
© SQLI2021
2013 104
WORKFLOW
KEY CONCEPT
@SQLI
© SQLI2021
2013 105
WORKFLOW
@SQLI
© SQLI2021
2013 106
WORKFLOW
WORKFLOW EXTENSION
@SQLI
© SQLI2021
2013 107
Ca
ch
e
CACHE
@SQLI
© SQLI2021
2013 109
CACHE
@SQLI
© SQLI2021
2013 110
CACHE
@SQLI
© SQLI2021
2013 111
CACHE
@SQLI
© SQLI2021
2013 112
CACHE
@SQLI
© SQLI2021
2013 113
CACHE
@SQLI
© SQLI2021
2013 114