Essential Hybris Services


The services listed below are intensively used in SAP hybris development. It is not a full list of hybris services, but these are used almost in every project. In order to prioritize the services, I used the following bash command launched in the hybris home directory:
find . -name *-spring.xml | xargs cat | grep 'property name=' | grep ' ref=' | perl -npe 's/^(.*)ref="(.*)"(.*)$/\2/g' | grep Service | sort | uniq -c | sort -nr
I also extracted beans under @Resource and @Autowired annotations and combined the results with what I got from the bash script. The quick reference below helps with understanding the important concepts on how services work and where they are used. For all services, the corresponding beans have the same name (start with a lowercase as per beans naming convention)

ModelService

  • SAP Hybris model management. Creating, loading and writing of the hybris data models (Item).
  • key operations:
    • create,
    • get/get by example,
    • attach/detach,
    • clone,
    • save,
    • remove,
    • enable/disable transactions,
    • get/set attribute value
  • it is a generic interface to the hybris persistence layer. If you need to retrieve or create the item, you eventually use this interface directly or indirectly

UserService

  • user management (such as employees, customers etc)
  • key operations:
    • get user by id,
    • get usergroup by id,
    • get/set current session user,
    • get/set passwords
  • deals primarily with UserModel/EmployeeModel/CustomerModel and UserGroupModel

CatalogVersionService

  • Provides basic catalog version oriented functionality (such as Online, Staged…).
  • key operations:
    • get/set/add session catalog version,
    • fetch catalog version model by catalog and version name,
    • find duplicated ids,
    • determining whether user is eligible for read/write operations within the given catalog version
  • deals primarily with CatalogVersionModel and CatalogModel

FlexibleSearchService

  • SQL-like search on hybris item types.
  • key operations:
    • search,
    • get model (s) by example,
    • translate to SQL
  • on top of Jalo (old) FlexibleSearch

ProductService

  • product management
  • key operations:
    • get product by code,
    • catalog version,
    • get product for category,
    • get all products for catalog version
  • mainly uses ProductDAO as an interface. ProductDAO mainly uses FlexibleSearchService to access the items.

TypeService

  • hybris type management
  • key operations:
    • get composed/atomic/enumeration type by code/class,
    • get attribute descriptor for a type by qualifier,
    • get all attribute descriptors,
    • get enumeration values,
    • get mandatory/unique attributes,
    • get default values for a type
  • deals with TypeModel, DescriptorModel
  • mainly uses TypeDAO as an interface. TypeDAO mainly uses ModelService to access the items.

CommonI18NService

  • Country, language, currency management
  • key operations:
    • get locale for a language / iso code
    • get language for isocode
    • get/set current language / currency
    • get country by isocode
    • get region by country and region code
    • get currency for a currency code
    • get base currency
    • get all countries / regions / currencies
    • convert/round currency
  • deals with CountryModel, CurrencyModel, LanguageModel and RegionModel
  • mainly uses CountryDAO / CurrencyDAO / LanguageDAO / RegionDAO as interfaces to a persistence layer.
  • uses a conversion strategy (redefinable) for convert/round operations

I18NService (deprecation)

  • General international support service, an interface to Java Internationalization/Localization API: Locale, Currency, TimeZone
  • key operations:
    • get/set current locale/timezone/currency
    • get supported locales
    • get/set language fallback
    • get fallback locales
    • get currency by isocode
  • deals with CountryModel, CurrencyModel, LanguageModel and RegionModel
  • uses the following services:
    • locale service

BaseSiteService

  • Base sites management
  • key operations:
    • get all base sites
    • get base site for uid
    • get/set current base site
    • get product catalogs for a base site
  • deals with BaseSiteModel
  • mainly uses BaseSiteDAO as an interface. BaseSiteDAO uses FlexibleSearchService to access the items.
  • uses the following redefinable services:
    • session service

CartService

  • Cart management
  • key operations:
    • add to cart
    • get/set/remove session cart
    • calculate cart
    • update quantities for a cart
    • merge carts (append)
    • change user for a cart
    • create cart from a quote
    • clone a cart
    • get/add/remove global discounts
    • get/add/remove total tax values
  • deals with CartModel, QuoteModel, ProductModel, OrderModell, OrderEntryModel and others.
  • uses the following redefinable strategies:
    • add to cart strategy
    • order calculation strategy
    • create cart from quote strategy

SessionService

  • Session management
  • key operations:
    • get current session
    • create new session
    • close session and close current session
    • get/set/remove session attribute
    • get all session attributes
    • executing code in the local session context (+with params / for a specific user)
  • uses JaloConnection, JaloSession

ConfigurationService

  • Access to hybris configuration
  • key operations:
    • retrieve hybris configuration

CalculationService

  • calculation the order / cart (entries, discounts, taxes)
  • key operations:
    • (re-) calculate the order (+for a particular date in the past or future)
    • check if calculation is required for an order
    • calculate totals (faster, doesn’t trigger the tax/price/discount calculations)
    • recalculate the cart/order entry
  • deals mainly with AbstractOrderModel
  • uses other redefinable services
    • Model Service
    • Commerce Price Service
    • Base Site Service
    • CommonI18NService
  • uses the following redefinable strategies:
    • Find Discount Values Strategy
    • Find Tax Values Strategy
    • Find Price Strategy
    • Find Delivery Cost Strategy
    • Find Payment Cost Strategy
    • Order Requires Calculation Strategy

IndexerService

  • solr search index operations
  • key operations:
    • perform full index
    • update index (+for a particular type, for particular items, for particular indexed properties)
    • delete index (+of a particular type, particular items)
  • uses the following redefinable strategies:
    • Indexer Strategy (responsible for creating and executing of the indexer workers)

CronJobService

  • cronjob management
  • key operations:
    • perform given cronjob, synchronously or not
    • request abort cronjob
    • get cronjob by code
    • get job by code
    • cronjob execution status (successful or not, error or not, finished or running)
    • get cronjob logs (as text)
  • deals mainly with CronJobModel, JobModel
  • uses redefinable services
    • Tenant Service
    • Cluster Service

MediaService

  • media management
  • key operations:
    • get/set stream/raw data of/to the file from/of the media object
    • add/remove version streams for a media
    • get/set url/stream for media version
    • set media folder for a media
    • get media folder by qualifier
    • get root folder
    • get media format by qualifier
    • move media to folder
    • copy/duplicate/move data from a media to another media
    • get media by code/format

FacetSearchService

  • solr facet search operations
  • key operations:
    • create search query / create populated search query to use with search
    • create free search query for a user query to use with search
    • search query
  • redefinable strategies:
    • Facet Search Strategy (implementation of search)

OrderService

  • order management
  • key operations:
    • create order from cart
    • submit an order
    • add new entry to an order
    • clone an order
    • get/add/remove global discounts
    • get/add/remove total tax values
  • uses redefinable strategies
    • place order strategy
    • order calculation strategy
    • create order from cart strategy
    • submit order strategy

BusinessProcessService

  • business process management
  • key operations:
    • create a process
    • start a process (by process code)
    • get a process by process code
    • trigger an event
    • restart the process

BaseStoreService

  • base store management
  • key operations:
    • get all base stores
    • get base store by id
    • get current base store
  • uses a redefinable strategy:
    • baseStoreSelectorStrategy (implements getCurrentBaseStore)

CatalogService

  • catalog management service
  • key operations:
    • get all catalogs (+of a particular type)
    • get catalog for catalog id
    • get default catalog
    • get session catalog version
  • uses redefinable services:
    • catalog version service

SiteConfigService

  • site config management service
  • key operations:
    • get property by name
  • uses redefinable services:
    • configuration service
    • base site service
    • UI Experience Service

EventService

  • event management service
  • key operations:
    • publish an event
    • register event listener
    • unregister event listener
  • uses redefinable services:
    • tenant service
    • cluster service

CMSSiteService

  • cms site management service
  • key operations:
    • get all catalogs of a site
    • get product catalogs of a site
    • get all sites
    • get all classification catalogs of a site
    • get/set current catalog version
    • get/set current site
    • get site for URL
    • get start page label or if for a site
  • uses the following redefinable services:
    • catalog version service

CategoryService

  • category management service
  • key operations:
    • get root categories (+for catalog version)
    • get category by code
    • get categories having the particular code
    • get category path for a product
    • get category path for a category
    • set allowed principals for category / all related categories
    • get all sub/super categories for category
  • uses the following redefinable services:
    • catalog version service
  • uses the following redefinable strategies:
    • categoryPrincipalStrategy

CMSPageService

  • cms page management service
  • key operations:
    • get all active page templates
    • get all content pages
    • get (own) content slots for a page/page template
    • get default catalog / category / content / product page
    • get default page by label
    • get homepage
    • get label or id for a page
    • get page by catalog / catalog id / category / category code / id  / label and page statuses / label or id / product / product code
    • get pages by page template content slots
    • get pages for component / content slots / page template component / page template content slots
    • get sorted multicountry content slots
  • uses the following redefinable services:
    • cms restriction service
    • catalog service
    • category service
    • product service
    • type service
    • configuration service
    • catalog version service
    • cms catalog level service

CMSComponentService

  • cms component management service
  • key operations:
    • get cms component by code (+and catalog version)
  • uses the following redefinable services:
    • type service
    • catalog version service

PromotionsService

  • promotions management service
  • key operations:
    • get promotions for a product and promotion groups (+for a specific date in future or in the past)
    • get order promotions (+for a specific date in future or in the past) (+for a product)
    • update promotions for an order (+by a specific date)
    • get promotion results from the order
    • delete stored promotion results for a cart
    • transfer the promotions applied to a cart to a new order
    • get promotion restrictions
    • get promotion group

Leave a Reply