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. 



No comments:

Post a Comment