Adding Functionality to Administration Console

You can add your own functionality to SAP Commerce Cloud Administration Console based on the yhacext template. Use the extgen generator to create a new extension from the template. Then implement the logic for your new extension in this template.

During the Platform build process, your new extension adds its controllers, jsp pages, css and javascripts to the hac extension - all packed into a jar package located in <HYBRIS_BIN_DIR>/platform/ext/hac/web/webroot/WEB-INF/lib. On starting up, Administration Console registers these controllers and provides the jsp pages, css and javascript resources for use.

Your new extension enables you to create your own tabs with subtabs that display in Administration Console. In subtabs, you can configure url addresses to correspond with the mapping of your controllers.

New Extension Directory Structure

The Enhanced1 extension has the following directory structure:

Directory Description
/hac/src/de/hybris/platform/hac/controller/ Custom controllers provided by extension
/hac/resources/jsp/ Custom jsp views
/hac/resources/static/css Custom css resources
/hac/resources/static/js Custom javascript files
/resources/enhanced1-tab-config.json Default-extension tab configuration (defined as bean in /resources/yhacext-spring.xml)
/resources/ Extension items, beans, and spring configuration files
/hac/testsrc/de/hybris/platform/hac/controller Unit tests for custom controllers

Adding Your Functionalities to Administration Console

To add new functionalities to Administration Console follow the procedure.

Procedure

  1. Create a new extension from the yhacext template. For details, see Creating a New Extension.
  2. Implement your business logic in your new extension.

    When you add a new controller, remember to place it inside the de.hybris.platform.hac.controller package located in the <HYBRIS_BIN_DIR>/custom/Enhanced1/hac/src directory.

  3. Add your new extension to the<${HYBRIS_CONFIG_DIR}>/localextensions.xml so that Platform can see it and then load it.
  4. Build Platform, start the server and log into Administration Console.
    You should see the YHacExtension tab and the Statistics subtab. Notice that it is only a default extension page - implement your own functions for your tabs.

Adding New Tabs to Administration Console

You can create tabs in your new extension thanks to a spring bean defined in the Enhanced1-spring.xml file.

Context

The file is located in the<HYBRIS_BIN_DIR>/custom/Enhanced1/resources directory. The bean is defined as follows:
<bean id="Enhanced1HacTabsConfig" class="de.hybris.platform.hac.custom.JsonHacConfiguration">
   <property name="resource" value="classpath:Enhanced1-tab-config.json"/>
</bean>

New tabs are displayed just like all other tabs in Administration Console. The tabs that you create can only perform the logic that you implement in your new extension. You cannot change the tabs that are defined for the original Administration Console.

To add a new tab to Administration Console follow the procedure.

Procedure

  1. Open the enhanced1-tab-config.json file.
  2. Use the template provided and configure the file to your needs.
    [ {
      "basePath" : "/Enhanced1",
      "mainTabLabel" : "yHac extension",
      "subTabs" : [ {
        "path" : "/extension/",
        "label" : "extension",
        "skipPrefix" : false
      }, {
        "path" : "/statistics/",
        "label" : "Sample stats",
        "skipPrefix" : false
      } ]
    }, {
      "basePath" : "/Enhanced1",
      "mainTabLabel" : "Enhanced1b",
      "subTabs" : [ {
        "path" : "/extension/",
        "label" : "extension",
        "skipPrefix" : false
      }, {
        "path" : "/statistics/",
        "label" : "Sample stats",
        "skipPrefix" : false
      } ]
    } ]
  3. Restart the SAP Commerce Cloud Server.

    It is necessary to restart the SAP Commerce Cloud Server to display the new tabs - you don't have to rebuild Platform.

    The code provided generates two tabs:

Enhanced1-tab-config.json Configuration

The configuration is a json array of objects that configure each tab and subtabs.

The following table lists the enhanced1-tab-config.json configuration attributes for tabs:

Tab definition

Description

mainTabLabel

Tab label displayed by Administration Console

basePath

Url prefix shared by all subtabs

subtabs

Array of subtabs

The following table lists the enhanced1-tab-config.json configuration attributes for subtabs:

Subtab definition

Description

path

The url a subtab points to. It is appended to mainTabLabel.

label

Subtab label displayed by Administration Console

skipPrefix

Decides if a path should be appended to basePath or just path should be used.