Addon Concept Hybris

Addon

Addon is also kind of extension 
It is generally used to enhance the existing functionality
Addon is used to extend the Functionality without editing the core code. Technically Addon is a regular extension but whenever we build its codebase is copied inside target extension.In short we can say it as plug and play functionality.

Hybris OOTB provides multiple Addons like captcha Addon, asm Addon, secure portal Addon etc.

Key Features

Modular

  • Addon frontend files are separate from the rest of the frontend lines.
  • AddOns are self contained.

Reusable

  • Use any combination of AddOns in different projects.
  • Essential step for hybris extend.
  • Upgrading accelerator won’t overwrite your files.

Pluggable

Easily remove AddOns.

Creating Addon

AddOns allow you to extend storefront extensions without having to modify the extensions directly. In addition to simply using the preconfigured AddOns provided by SAP, you can create your own custom AddOns. to do so you create a blank AddOn, install it and then modify its logic.

To create empty Addon

In the command prompt or Terminal

<HYBRIS_HOME>/hybris/bin/platform folder

Run the appropriate command

  • setantenv.bat for Microsoft Windows system.
  • . ./setantenv.sh on Linux or MacOs.

Create new extension named myextension. it will created under <HYBRIS_HOME>/hybris/bin/custom.

ant extgen -Dinput.template=yaddon -Dinput.name=myextension -Dinput.package=com.myapp.myextension

open the <HYBRIS_HOME>/hybris/config/localextensions.xml file and add your new extension.

<extension name="myextension" />

Lets see an example:

  1. include in localextensions.xml
<extension name="addonsupport" />
<extension name="AddOnname" />

2 .Add a <requires-extension> tag identifying each AddOn in your storefront’s extensioninfo.xml

3. Add the following to your AddOn’s project.properties:

<storefrontTemplateName> .additionalWebSpringConfigs.

AddOnName=classpath:/AddOnName/web/spring/AddOnName-web-spring.xml

Using Ant you can do above 2&3 steps:

ant addoninstall -Daddonnames="AddOnName"-DaddonStoreFront.yacceleratorstorefront="storefrontName"

4. Make its controllers visible in AddOnName-web-spring.xml

<context:component-scan
        base-package="<packagename>.controllers"
        scope-resolver="de.hybris.platform.spring.
                             IgnoreTenantsScopeMetadataResolver"/>

Go for Build

Leave a comment