Steps to Create a New Extension?

To create a new extension:

  1. Optionally: Modify default values for the extension generation process.
  2. Create a new extension.
  3. Reference the new extension in the localextensions.xml file.
  4. Rebuild the hybris Commerce Suite.
  5. Update the hybris Commerce Suite.

Afterwards, you can start implementing your business logic in the new extension.

The hybris Commerce Suite comes with an extension generator system called extgen located in the ${HYBRIS_BIN_DIR} /platform/extgen/ directory. Using extgen, you can create new extensions based on extension templates.

Creating a New Extension:

Step 1: Optional: Setting Default Values for New Extensions

You can personalize extgen default behavior by modifying the project.properties file located in ${HYBRIS_BIN_DIR} /platform/extgenExtgen  then uses your settings as the default to generate the extension.

Modifying the default values is only necessary for advanced settings. Extgen prompts you to provide the basic values during the extension generation process.

Step 2: Copy an Extension Template Using Extgen

An extension template is a predefined basic extension to be duplicated. The copy serves as a starting point for creating a new extension, typically used for a customer specific implementations.

  1. Open a command prompt.
  2. Navigate to the ${HYBRIS_BIN_DIR} /platform directory.
  3. Run the ${HYBRIS_BIN_DIR} /platform/setantenv.bat file. Do not close the command prompt as the settings are transient and are lost if the command prompt is closed.
  4. Run ant extgen in ${HYBRIS_BIN_DIR} /platform directory. This internally runs ant in the extgen directory.
Extgen prompts you to specify values for the technical aspects of an extension. Extgen comes with default values for all these technical aspects. These default values are defined in the project.properties file in the extgen directory. The default value is displayed in brackets ([ and ]), such as:
Press [Enter] to use the default value [training]
 You can simply use the default value by pressing Enter.
Note:
Not All Possible Configuration Settings Are PromptedExtgen only prompts you for the most important values for your extension. To modify some advanced settings such as the extension directory, you need to modify the project.properties file in the extgen directory.

Extgen prompts you to specify:

  • The extension's name.
  • The extension's Java package.
  • The extension template to use. 

After you have provided the prompted values, extgen:

  1. Copies the extension template to a temporary directory.
  2. Modifies the extension template to reflect the specified values.
  3. Copies the new extension from the temporary directory to the directory specified by the extgen.extension.path property in the project.properties file.

After the copy process is completed, the extension is ready to be referenced in the localextensions.xml.

Step 3: Reference the New Extension in localextensions.xml File

To make sure that an extension is integrated into the build framework, you need to reference the extension 

in the localextensions.xml file. Please note that by default this file only contains references to folders 

from which it loads all extensions:

localextensions.xml

<path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-platform"/>

<path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-cockpit"/>

<path dir="${HYBRIS_BIN_DIR}"/>

Hence, if you want to add a new extension, myextension, add this line

to localextensions.xml:

localextensions.xml

<extension name="myextension"/>

Step 4: Rebuild the hybris Commerce Suite

  1. Open a command prompt. 
  2. Navigate to the ${HYBRIS_BIN_DIR}/platform directory. 
  3. Make sure that a compliant version is used: 
    • On the Windows operating system, call the ${HYBRIS_BIN_DIR}/platform/setantenv.bat file. Do not close the command prompt after this call as the settings are transient and would get lost if the command prompt is closed. 
    • On the Unix operating system, call the ${HYBRIS_BIN_DIR}/platform/setantenv.sh file, such as: . ./setantenv.sh
  4. Call ant clean all to build the entire hybris Commerce Suite

Configure an Extension:

An extension is configured by the extensioninfo.xml file. It defines the contained extension modules 

and list of extensions that the current extension depends on.

To define properties of the extension, use the local.properties file. 



Define Product Cockpit?

  • Hybris Product Cockpit Module enables cockpit end users to manage and structure product information and catalogs in high-volume and collaborative environments. 
  • Product managers can visualize their input from multiple perspectives and make product management processes more efficient.
  • Several perspectives enable users to concentrate on the most important aspects of individual tasks, such as managing product data or structuring categories.
 1.    Managing Product Data:
  • Organizations ideally want to administer and edit information about different product lines and multiple products with varying attributes from within a single user interface. 
  • Available software, however, may offer product managers limited data management capabilities. They may not be able to customize the user interface to meet their specific needs and preferences. 
  • And employees often work across multiple systems that are not integrated, which can create collaboration challenges.
 2. Use the Hybris Product Cockpit for Managing All Product Information in One Place:
  • The Hybris Product Cockpit is a highly customizable graphical user interface that makes product data management more efficient, process-oriented, and user friendly. 
  • Perspectives can be configured to display role-based sets of user interface elements. Mass data management capabilities support and simplify workflows and synchronization. 
  • As a pre-configured application, the Hybris Product Cockpit supports customizations - such as changing the front-end configuration or adding custom front-end elements - without requiring additional implementation work. 
  • You can manage all kinds of product information and multimedia with the Hybris Digital Asset Management module. 
The Hybris Product Cockpit is an ideal product data management solution that delivers both excellent usability and significant potential cost savings.

3. Benefits:
The Hybris Product Cockpit provides you with the following benefits:
  • Streamlining catalog and product management through its well-structured user interface.
  • Supporting typical working processes through a fully customizable user interface.
  • Optimization of team work by managing even complex workflows.
  • Facilitating efficient mass data management.
  • Providing seamless workflow management through tracking, commenting, and status changes.
  • Delivering a thin client with rich user experience, such as drag and drop, favorites, and so on.
  • Support for product-related workflow tasks and synchronization.
  • Validation rules to control data formats.
  • Support for extensive product comparisons.
  4. Business Impact:
  • Employees across subsidiaries and departments can access centralized information via role-based security profiles, ensuring that users only view or edit content that is relevant to them. 
  • Access rights can be defined for various product attributes, product classes, or catalog versions. 
  • The Hybris Product Cockpit is ideal for businesses with distributed product content responsibilities, as content managers can work on staged product versions, without affecting the live version displayed on the website.
  5. Features:
  • Ability to view products, product categories, and product attributes in different perspectives
  • Catalog perspective for working with catalog versions and categories
  • List views of product result sets
  • Grid views of product result sets
  • Ability to set references to product-related business objects such as units, media, catalog versions, prices, etc
  • Mass data editing while using the list view
  • Ability to move data via copy/paste
  • Customization of views at runtime, for example add or remove list columns, sections, or fields
  • Switchable user roles
  • User-based lists of favorites
  • Easy handling of workflow actions like tracking, commenting, and changing status
  • Synchronization of single products, categories, or catalog versions
  • Integrated digital asset management, requires Hybris Digital Asset Management module

What is the difference between hmc and hac?

Hybris Management Console (HMC):
Hybris Management Console (HMC) is the administration tool for Hybris Commerce. Using the HMC, you can manage SAP Hybris Commerce business objects such as products, customer data, and orders.

Hybris Administration Console (HAC):
The Hybris Administration Console is an administration Web page provided by the hac extension.
It provides functionality for administration, monitoring, and configuration of SAP Hybris Commerce.
In addition, it links to the documentation resources for SAP Hybris Commerce.

What is the difference between ‘generate’ and ‘autocraete’ elements of an attribute in items.xml and why are they used?

The attribute elements 'generate' and 'autocreate' plays major role in the below two scenarios:
  • While we create subtypes and add attributes to the subtype.
  • While we add new attribute to an existing type directly.
Case 1: Creating a Subtype
autocreate -
The first definition of a type ( or subtype of a type ) should set the 'autocreate' flag to 'true'.
A 'true' value lets the hybris Commerce Suite create a new database entry for this type at initialization/update process.
e.g.
<itemtype code="MyProduct" autocreate="true" generate="true" extends="Product" jaloclass="org.training.jalo.MyProduct">

    <attributes>

        ...

    </attributes>

</itemtype>
 Here setting the ‘autocreate’ modifier to false will cause a build failure.
generate -
Setting the generate modifier to true will result in Java class files being generated for this type (additional details).
Setting the generate modifier to false will result in no Java class file being generated for this type.
Having no Java class file available will mean that we will not be able to implement custom business logic (such as getter, setter methods) for the type. And we will have to make use of the super type’s business logic implementation.
Case 2: Creating a Subtype
autocreate -
In this scenario as the type basically exists already, we need to set the 'autocreate' modifier for the type definition to 'false'.
e.g.
<itemtype code="Product" autocreate="false" generate="false">

    <attributes>

        <attribute qualifier="oldPrice" type="java.lang.Double" generate="true">

            <persistence type="property"/>

            <modifiers read="true" write="true" optional="true"/>

        </attribute>

    </attributes>

</itemtype>
Setting the autocreate modifier to true will result in a build failure.
generate - The value of the generate modifier is ignored in these scenario.

Define Extension Template and how to add a custom template?

The Hybris Templates package provides a collection of sample functionality, ready to use as a starting point for developing your customized solutions.

The source code of the included Template modules is accessible and ready to be adapted.

SAP Commerce Cloud comes with multiple extensions templates that you can use for new extensions.

Extension Template

Documentation

yempty

yempty Extension Template

yvoid

yvoid Extension Template

yaddon

yaddon Extension

ybackoffice

Structure of the Custom Backoffice Extension

yacceleratorcore

yacceleratorcore Extension

yacceleratorfacades

yacceleratorfacades Extension

yacceleratorstorefront

yacceleratorstorefront Extension

yacceleratorcockpits

yacceleratorcockpits Extension

yacceleratorinitialdata

yacceleratorinitialdata Extension

yacceleratortest

yacceleratortest Extension

ycommercewebservices

ycommercewebservices Extension

yacceleratorordermanagement

yacceleratorordermanagement Extension

yacceleratorfulfilmentprocess

yatddtests

ycommercewebservicestest

ycommercewebservicestest Extension

ydocumentcart

ydocumentcart Extension Template

yoccaddon

yoccaddon Extension

yocc

yocc Extension

yocctests

yocctests Extension

yhacext

Adding Functionality to Administration Console

Adding a Custom Template:

To add your own template extension to the selection of extgen templates please add the following line to the extensioninfo.xml of your template extension.

<meta key="extgen-template-extension" value="true" />

Extension overview in SAP Commerce?

  • The hybris Commerce Suite is based on a flexible, modular concept that allows you to put new functionality into extensions.
  • An extension is an encapsulated piece of the hybris Commerce Suite that can contain business logic, type definitions, a web application, or a hybris Management Console (hMC) configuration. 
  • Because extensions are independent of one another by default, you can migrate an extension from one hybris Commerce Suite version to another.

Basic Structure of an Extension:

    An extension based on the yempty extension template contains the following directories and files:

Directory or File of a Blank Extension

Description

/.externalToolBuilders directory

Contains the Eclipse builder that automatically generates hybris Models if any extension's items.xml file has been modified in Eclipse.

/.settings directory

Contains configuration files for Eclipse in general and Eclipse-related Spring configuration files.

/lib directory

All external library files should be stored here.

/resources directory

Contains the $extension -items.xml file and the localization for the extension types (within the /localization subdirectory).

/src directory

Contains the source code files for the extension's core extension module.

/testsrc directory

JUnit test files for the extension are located here.

/web directory

This directory contains the web extension module parts of the extension (JSP files, libraries). Sources and resources from this directory are only accessible to a Web application containing the extension. They cannot be accessed from another extension.

.classpath file

Classpath file for Eclipse.

.pmd file

Control file for PMD with hybris specific settings.

.project file

Project file for Eclipse.

.ruleset file

Ruleset file for PMD with hybris-specific settings.

.springBeans file

Configuration for Spring IDE Eclipse plugin.

buildcallbacks.xml

Allows you to implement custom build framework logic.

extensioninfo.xml file

Configures the extension modules. This file is used by the build framework. It also determines which extensions are required for proper functioning.

project.properties file

Configuration properties for the extension.

external-dependencies file

Third party dependencies of Hybris Commerce extensions are defined here.

  • The directories and files above exist after the extension is generated (or after ant clean is run). During an extension build, some additional directories and files are created:

Directory or File of a Blank Extension

Description

platformhome.properties

Automatically generated file. It contains only the relative path to ${HYBRIS_BIN_DIR} /platform . Do not modify it.

extensioninfo.xsd

Copied from ${HYBRIS_BIN_DIR} /platform/resources/schemas . Allows validating the extensioninfo.xml file.

build.xml file

This build file calls the platform's build file for actual action and provides the necessary parameters to it. This way ant targets are consistent throughout the entire installation.

/classes directory

Contains all .class files for src , testsrc and gensrc folders of the extension.

 Checking Installed Extensions:

To check the installed extensions of the hybris Commerce Suite do the following:

  • Open the hybris Administration Console.
  • Go to the Platform tab and select Extensions option.
  • The Extensions page displays with list of all installed extensions

Extension Modules:

The following extension modules can be available per extension:

Extension Module

Contained Functionality

Core

Declarations and localizations of types, Jalo item classes

Hmc

hybris Management Console (hMC) configuration and localization for it, custom hybris Management Console elements, such as editors, tabs, display chips.

Web

Web application

 An extension is configured in the extensioninfo.xml file. It defines the following:

  • A list of extensions required for current extension. If the required extension does not exist in your installation, then the build of the hybris Commerce Suite fails.
  • A list of available extension modules with their configuration:
  • core extension module: Among other things, you can define whether item and extension classes will be generated or not.
  • web extension module: Among other things, you can define webroot of the Web application.
  •  hmc extension module