Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

6 addons

Markus Perndorfer edited this page Dec 5, 2018 · 1 revision

Addons

Tag
6-addon

Run a hybris update after checking out this tag:

cd hybris/bin/platform
ant clean all
ant updatesystem -DconfigFile=../../config/update-addon.json -Dde.hybris.platform.ant.production.skip.build=true

This should add a CowComponent to the electronics demo store homepage.

Intermission: Configure the update running system from the command line

If you want to know more about -DconfigFile, check Updating SAP Hybris Commerce from The Command Line

I did use one trick to ensure that the patch method CowComponentAddonSetup#addCowToHomepage is executed:

  1. Set the project data checkbox for the extension whose patches you want to have imported in the hac

  2. dump config

  3. remove the patch_<extension> array, eg:

    "patch_cowaddon": [
    "e7b26c13b1c5d731f69b91ec6d9b21fa"
    ],
  4. remove the last line, filteredPatches:

    "filteredPatches": "true"

This ensures that every not-yet-processed patch is executed.

If you're wondering what a "patch method" is: Patching Framework

Addons Tips & Tricks

With the setup out of the way, let's talk about addons, one of the more "interesting" concepts of SAP Commerce.

The purpose of an addon is to modify the accelerator storefront, without actually touching the source of the storefront.

To accomplish this, there is a lot of magic in the platform build surrounding the acceleratoraddon folder of an addon, but it boils down to:

  1. copy the files/folders from addonextension/acceleratoraddon to the appropriate folders of the storefront extensions
  2. (re)build the storefront with the freshly copied sources/files from all addons

This means to optimize the developer flow for addons you have to remember one thing:

Everything in acceleratoraddon actually belongs to the storefront

Following this principle, here are some rules of thumb:

  • If a change happened somewhere in addonextension/acceleratoraddon -> build the target storefront
  • For anything else -> build the addon extension.

All the coping / rebuilding happens in the after_build callback of the storefront, this means you have to build the storefront (not the addon!) if you:

  • changed the js / less files of your addon
  • changed the source code of a controller that belongs to your addon

If the Addon Filter is activated for the storefront, which it is out-of-the-box, a simple page reload should be enough to see any changes to jsp/tag/js/css files of your addon.
If it doesn't work, build the storefront

Combining DCEVM plus the hybris integration plugin works quite well for java / code changes, as long as you don't change the Spring config in any way.

In short: changing the code, adding / removing methods, changing the implementation works 90% of the time.

As soon as you touch anything related to Spring e.g. @Controller, @RequestMapping, adding / modifying beans in the Spring xml config files, injecting new dependencies etc, you have to restart.

Only JRebel provides support for hot swapping the Spring configurations

Testing addons

All tests found under addonextension/acceleratoraddon/web/testsrc are copied to the target storefront, as anything else in acceleratoraddon.

To make it more complicated, the addon tests are so called "web tests", and to execute those you have to pass an additional flag to the appropriate test ant target, for example:

ant unittests -Dtestclasses.web=true
Clone this wiki locally