GTM snippet

Monday, February 17, 2020

Extensions

Extension Structure

Extension Modules
Extension Modules are structural elements of an extension. Each of them offers a certain set of functionality.
Extension Module
Functionality
Core
Declarations of types, items, classes
Web
Web application

Core Extension Module:

The core extension module of an extension covers several basic components.

Type System Definition: Defined in item.xml in xml format file name pattern is always defined as <$extension> -items.xml
Java Source Code Files: Java source files of an extension.
Extension Version: Resource directory contains a file called <$extension>.<build.number>
Localization Files: Contains the localization files for the extension’s type and type’s attribute.

Web Extension Module:
The web extension module is the part of an extension that is accessible via browser.

Extensions can be added through localextensions.xml file located in config directory.
Extensions can have a core module or web module or it can be both.
Extension is configured by extensioninfo.xml file. It defines list of extensions required for current extension. If required extension does not exist in installation then build will get fail.

We can change the webroot path of an Extension for this we need to modify local.properties file we need to add a line 
hac.webroot=/admin
storefoundation.webroot=/storefoundation
The default web application of SAP commerce that is launched is hac console. It is not recommended to set this as a default web application in live environment. To set HAC no longer be the default web application we need to modify local.properties file
Hac.webroot=/admin

Creating a New Extension

SAP commerce comes with an extension generator system called extgen. Using extgen we can create new extensions based on extension templates there are number of extension templates available.
To make any of your extension serves as template extension add following line to the extensioninfo.xml file
<meta key="extgen-template-extension" value="true"/>
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. Don't 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]
Extgen prompts you to specify:
·       The extension's name.
·       The extension's Java package.
·       The extension template to use.
After these steps give custom extension reference in localextensions.xml file
<extension name=”customExtension”>
Rebuild the SAP commerce
1.       Open a command prompt.
2.       Navigate to the <HYBRIS_BIN_DIR>/platform directory.
3.       Make sure that a compliant version is used:
o   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.
o   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 SAP Commerce.

There are 21 Templates Available to select from while creating extension