天天看点

SAP Commerce(SAP Hybris)学习资料汇总

导航目录

SAP官方帮助文档

configuration

如何运行

Filters

容器化支持

Installer-Recipe

Extension和Addon的概念

一步步创建一个新的addon

如何处理dependency

localextensions.xml

Internationalization-and-localization

ant

Hybris-initialization和update过程

Model

SAP-Commerce里的Spring框架

AOP

[一个向导]

Accelerator

API-registry

search-and-navigation

solr-server

Module

开发环境相关

Service-Layer

Interceptor

Hook

event-system

Hybris-Type-System

Platform-Services-and-Utilities

platform module feature

platform module architecture

platform module implementation

Distribution-process

cache

Charon

Cluster

container-support

filters

Impex - 使用api导入导出数据

Internationalization-and-Localization

Jalo-Layer

Jalo-session

logging

media

oauth2

order

europe1

Ordering-Process

payment

Processing

Global Templates

Product建模的两种方式

type-system

所有可用的类型列表

items.xml详述

dynamic-attribute

Enumerations

script

search

Chinesepaymentservices

backoffice

其他网友的资料

SAP成都研究院Commerce开发人员Zhang Jonathan的三篇概述文章:

Jerry Wang的文章:

其它文章:

配置文件和运行时在admin console里两种方式

The HYBRIS_RUNTIME_PROPERTIES environment variable allows you to set a path that points to a custom properties file.

运行时动态更新配置:RuntimeConfigLoader,定期轮询properties文件是否有变化。

配置文件的编码问题:encoding

默认: ISO 8859-1

configuration template是一系列配置文件的集合,分devlelop和production两种,结构如下:

A local.properties file

Configuration files for Apache Tomcat, such as wrapper.conf or wrapper-debug.conf

A license file

两种配置文件:project.properties and local.properties.

Project properties are the SAP Commerce defaults, while local properties is where you may define your own configuration for your extension.

The project.properties file is located in the /platform directory, and provides factory default settings. It is not recommended to edit this file.

The local.properties file is a working copy of the project.properties file, located in the directory. It allows you to override default settings from the project.properties file.

文件目录,层级结构

bin/platform: The core SAP Commerce platform extensions that are loaded on startup. This directory also has the build framework, and extension templates.

data: Data files such as media files and LucerneSearch indexes. The directory also contains HSQLDB data files, if you are using the default database in a test or development environment.

log: Log files, including Tomcat and JDBC logs.

NEVER change anything within the bin directory. Do not keep any custom data configuration in this directory or any of the subdirectories. The upgrade process may replace the bin directory and subdirectories with a newer version of SAP Commerce and remove your changes.

回到目录

系统最低需求

默认的数据库:HSQLDB

第三方软件需求

如何安装

SAP Commerce 1905 requires JDK 11 or later. It is fully compatible with SAP Machine 11.

如何下载安装包

Navigate to the <${HYBRIS_BIN_DIR}> /platform directory, call ant clean all to build the entire SAP Commerce solution.

包含一些默认filters的功能介绍。清单在这里

images

不能用于生产用途。文件夹位置:installer/recipes. 这个链接包含了所有recipe的说明。

License文件:/config/license/installedSaplicenses.properties

如何生成license file

也不能在一个目录里重复安装不同的recipe:

SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总

the web folder contains both the src and the webroot subdirectories. After putting all the components you want to add into the proper folders, you need to run the following command on your system: ant build.

一旦build,会自动拷贝文件到Storefront Extension里,自动创建新的文件夹来容纳拷贝的文件:

SAP Commerce(SAP Hybris)学习资料汇总

web/addonsrc, which contains the source code for each installed AddOn. This gets compiled automatically.

web/webroot/WEB-INF/addons, which contains all the front-end components, such as images, JSP files, HTML files, and TAG files.

acc一旦升级,也不会覆盖掉我们的addon.

如果addon里直接添加jsp,css,图片等,不需要build platform, 如果添加新的java code到target Extension,就需要build platform.

SAP Commerce(SAP Hybris)学习资料汇总

Addon里的accelerator文件夹是如何拷贝到Storefront文件夹里的?规则在这个链接里。

source: /acceleratoraddon/web/webroot/_ui

target: /web/webroot/_ui/addons/

source: /acceleratoraddon/web/src

target: /web/addonsrc/, 装的java代码。文件copy由build callback实现:

The system scans for every extension that has a specific acceleratoraddon folder. Marker folders are defined as follows:

${extension-path}/acceleratoraddon/web/webroot/_ui

${extension-path}/acceleratoraddon/web/webroot/WEB-INF

For each AddOn that is found, the system identifies the target extension.

For each resource that is found in the acceleratoraddon folder, the system copies the contents to the target extension.

addoninstall工具的用法

使用addon定制化Storefront

在beans.xml里也可以给DTO增加新的属性:

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="beans.xsd">
    
    <bean class="de.hybris.platform.commercefacades.product.data.ProductData">
        <property name="weight" type="int" />
        <property name="instruction" type="String" />
        <property name="additionalImage" 
                         type="de.hybris.platform.commercefacades.product.data.ImageData" />
    </bean>
    
    <enum class="de.hybris.platform.commercefacades.product.ProductOption">
        <value>DIMENSIONS</value>
        <value>MINIMAL</value>
    </enum>
</beans>      
SAP Commerce(SAP Hybris)学习资料汇总

这个

链接

包含了一个表格,可以查询Extension和Addon的ID和description.

  1. ant extgen
  2. 自定义Storefront
  • 总体架构
  • Extension专题
    SAP Commerce(SAP Hybris)学习资料汇总
    SAP Commerce(SAP Hybris)学习资料汇总
    SAP Commerce(SAP Hybris)学习资料汇总
    Initialization的过程generate the database schema and the type system, and import any essential system data.

Platform目录下执行:ant initialize

Update: items.xml里定义的新类型,会施加到类型系统里。

upgrade

非常详细的讲解CMS模型的网页

基于items.xml的定义生成types. 通过core extension实现。

SAP Commerce(SAP Hybris)学习资料汇总

Impex也是extension. Extension能使用其依赖的extension core module包含的resources和source,但web extension module的东西没办法访问。

Impex modifier列表

Abbreviations语法

导入product的例子:脚本

flexible search里的!感叹号的用法,exclude subtype

MediaDataTranslator负责导出media内容。

是Service Layer的foundation.

Dependent Injection: 组件的依赖不是其自身维护,而是配置在外部。

SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总

在platform文件夹下,Call ant clean all to build the entire SAP Commerce software package.

以debug方式启动服务器:hybrisserver.bat debug

创建新的controller和jsp view - hello world级别的

Product练习

Service extension

Extensibility的奥秘:platform/ext/platformservices/resources/product-spring.xml

SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总
主要模块 Architecture讨论 共有的一些Extension responsive? storefront 结构解析 technical design guide Accelerator for China

为什么要用alias?Extensibility!

SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总

Security

from jalo to service layer - migration and transition

after save event hook

startup tuning

disable JUnit tenant

suspend and resume

test with junit

mockito

China Accelerator

也是由一系列Extension组成。

用Eclipse搭环境

一定在build之后再导入import,否则报class找不到。

SAP Commerce(SAP Hybris)学习资料汇总

和persistence layer是松耦合的。

所有功能都通过service暴露:

Business Services implement business use cases, such as cart handling or back order.

Infrastructure Services provide the underlying technical foundation, such as internationalization, import, export, and so on.

System services provide functionality required by the ServiceLayer, such as model handling and session handling.

其实就是interface,通过models和其他service交互。

Strategy

A service may delegate parts of its tasks to smaller micro-services, called strategies. The service then serves as a kind of façade to the strategies.

Clients still use the service and its stable API. But under the hood the functionality is split into multiple parts. Because these parts are smaller and very focused to their task, it is easier to adapt or replace them. Strategies therefore help to further encapsulate behavior and make it more adaptable.

其实就是策略模式。

Models are a new way to represent SAP Commerce items. Each model contains all item attributes from all extensions thus unifying access to an item’s data. Models are generated from the type system of SAP Commerce.

Models are used by DAOs, services, strategies, converters, and facades.

SAP Commerce(SAP Hybris)学习资料汇总

Model可以从数据库load,用构造函数或者工厂方法新建。

Model context
  • ModelService

一个java bean:

SAP Commerce(SAP Hybris)学习资料汇总
  • Loading Models by pk
  • Loading Models from items
  • Creating Models
  • Updating Models
  • Deleting Models

增删改查CRUD方法都有。

只for model:

SAP Commerce(SAP Hybris)学习资料汇总
@SystemSetup(extension = MyExtension.EXTENSIONNAME)
public class SomeClass ... {
    @SystemSetup(extension = MyExtension.EXTENSIONNAME, process = Process.INIT, type = Type.ESSENTIAL)
    public void createImportantModelDuringInitProcess(){
       //create the model here
    }
...      

接收和发送commerce的事件。

event-service基于Spring event系统。

DefaultEventService allows you to register event listeners and publish events.

There is a DefaultEventService that implements the EventService interface (de.hybris.platform.servicelayer.event package). To use this service, add a Spring resource to your class.

@Resource
private EventService eventService;      
SAP Commerce(SAP Hybris)学习资料汇总

类型系统是对象的模板。platform里每个对象都是类型的实例。

Types定义了持久化对象:

Attribute存储对象的数据。

Deployment定义数据库表

java class

A Type is the type definition in items.xml and its Java implementation.

SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总
SAP Commerce(SAP Hybris)学习资料汇总

provides a range of features related to the main functionality of a SAP Commerce installation, that is, containerization, data management, synchronization, security, or localization.

build framework:code generation, jRebel

Caching, persistence layer的一部分,减少到db的query,详细在这, 也缓存flexible search结果。

Secure HTTP Transactions: Charon

Cluster 多节点共享数据库。

容器化 Platform, solr和data Hub需要打三个镜像。

data retension

data validation - before save: a JSR 303-compliant validation engine

digital asset management

filter for web application 一些常用filter列表:SessionFilter, ProfileFilter, Log4jFilter, RedirectWhenSystemIsNotInitializedFilter.

value change log

log

media - 文件系统上的文件。

SAP Commerce(SAP Hybris)学习资料汇总

[Product classification](The classification functionality enables you to define product attributes in a way different to the typing method. Classification-based attributes are called category features; they can also sometimes referred to classification attributes. Through classification, you can flexibly allocate category features that may change frequently. You can easily define and modify them because you manage them independently of the product type.)

classification - 另一套分类系统?

scripting engine

security

permission

cors support

SSO

User UML

strict mode严格模式

Suspend and resume

Workflow

SAP Commerce(SAP Hybris)学习资料汇总

extension列表:

catalog

commons: provides core helper methods for templates. These methods are used for media neutral handling of content to be exported.

formatter: converting item content to PDF, for example for converting an order to PDF.

Translator framework mainly used for converting of HTML documents to another format, for example to Adobe InDesign.

core extension: handles basic functionality such as persistence handling, the ordering process and contains the service layer functionality.

deliveryzone: ext下面。

hac. 可以只启动hac.

SAP Commerce(SAP Hybris)学习资料汇总

payment standard

platform services: forms a part of the SAP Commerce ServiceLayer and comprises the functional and business services.

processing: The CronJob Service, The Task Service, and the Process Engine.

tomcatembeddedserver : provides an API to run an embedded servlet container. The tomcatembeddedserver extension provides a Tomcat-based implementation of this API.

validation

ydocumentcart : template extension, allows you to store selected types in an alternative storage. It uses the polyglot persistence query language.

yempty: a predefined extension to be duplicated. The copy serves as starting point for creating a new extension, typically used for customer specific implementations. 还有yvoid.

build framework

只要在config文件夹localextensions.xml下面的Extension,都会被build framework控制。

ant target

在哪个目录下执行ant all决定了build scope:Platform-wide and extension-wide.

The SAP Commerce version is included in the build.number file located in the /platform directory.

build三大过程:

preparation: 检查环境变量的文件夹是否存在。然后解析dependency,如果A depends B,那么B一定先于A build. Build framework进行初始化操作,将build.xml拷贝到每个Extension的文件夹下。生成extenson的源代码。为Service layer生成model。不管是哪种build scope,这一步都会执行。

dependency update

extension building:before_build callback target, 运行validation,生成源代码文件,编译Extension的core和web module. 运行after build callback.

build过程中根据items.xml里的type definition创建java文件:

ServiceLayer的Model文件

Abstract Jalo Layer classes (carrying a prefix, such as Generated). These files are generated anew if you have modified the items.xml for the extension

Non-abstract Jalo Layer classes. These are only generated when the file does not yet exist. If a file with the same name exists, the file is not generated anew.

基于javac ant task,比较.java和.class的timestamp.

SAP Commerce(SAP Hybris)学习资料汇总

flexiblesearch也能被cache.

SAP Commerce(SAP Hybris)学习资料汇总

已经过时了,被Service layer取代。包含data model和用Java实现的business logic.

每次build都会根据items.xml生成abstract Java类和非abstract(只生成一次)

缺点是data model和Java类紧耦合,一旦data model变了,Java类也需要调整。所以被service layer取代了。很像gateway的SEGW里的DPC,DPC_EXT. 注意这两个Java类的位置不一样:

gensrc/de/hybris/jalolayer/sample/GeneratedMyType.java

src/de/hybris/jalolayer/sample/MyType.java

包含当前用户的数据和设置。

SAP Commerce(SAP Hybris)学习资料汇总

位置:

C:\Code\commerce-suite-6.7.0\hybris\bin\platform\ext\platformservices\src\de\hybris\platform\order

order service

DefaultOrderService: 在附近的impl文件夹内。行为抽象成strategy.

interface CreateOrderFromCartStrategy

SAP Commerce(SAP Hybris)学习资料汇总

CreateOrderFromCartStrategy

SaveAbstractOrderStrategy

DataAccessObjects

The europe1 extension handles all price, tax, and discount calculations in SAP Commerce.

Extensible Cart Calculation

Payment Transaction and Delivery Mode Handling

SAP Commerce(SAP Hybris)学习资料汇总

通过velocity script,一个template生成source code.

There are two default global templates to render beans and enums. These templates are used if there is no custom template defined for a specific bean or enum in the beans.xml file, or if a given template does not exist. The default templates are:

global-beantemplate.vm - for each bean

global-enumtemplate.vm - for each enum

SAP Commerce(SAP Hybris)学习资料汇总

service layer和jalo layer都和items.xml有关。

items.xml在Eclipse里修改之后立即生效的问题:

SAP Commerce comes with preconfigured builders for the Eclipse IDEInformation published on non-SAP site that support working with the items.xml file. Using Eclipse, whenever you edit an items.xml file, SAP Commerce automatically:

Jalo Layer: Generates Generated*.java source files (item classes) for all item types of your extension to the gensrc directory of your extension.

Jalo Layer: Refreshes the gensrc directory of your extension.

ServiceLayer: Generates *Model.java source files (model classes) for all item types of configured extensions to the bootstrap/gensrc directory

ServiceLayer: Refreshes the bootstrap/gensrc directory

Null Value Decorators in Models:类型JDK8的optional

items.xml的schema

deployment

什么时候需要指定一个deployment?

SAP Commerce(SAP Hybris)学习资料汇总

类型系统的清理cleanup

没有持久化存储,就是calculated fields

Groovy, BeanShell, JavaScript

flexible search: 执行过程分两阶段:

SAP Commerce(SAP Hybris)学习资料汇总
用代码的方式消费 paging分页机制 restriction限制条件 一些例子 tips and trips,技巧,最佳实践 Query and JDBC Hints

sample store

一个实际的例子:2455449 - How-to: Hide Backoffice explorer-tree nodes based on user access rights