In Hybris – Generate add-on from another add-on is many time a requirement where user’s want to extend but not customize some OOB add-on directly.
Unfortunately, there is no support for that out of the box, but with following trick, you can allow hybris platform to consider say cmsoccaddon as a template to generate a new one say mycmsoccaddon for you using ant extgen command.
Instead of wasting much time, let’s jump into the steps and example…
STEP 1 – Add meta tag to the extensioninfo.xml to hybris OOB addon
Tell your hybris platform that extension or addon you want to use is a template by adding this code to extensioninfo.xml
<meta key="extgen-template-extension" value="true"/>
With this, Running ant extgen from your platform, system will show you the edited add-on to select as a template to generate a new one.
STEP 2 – Create extgen.properties in parallel to extensioninfo.xml to hybris OOB addon
YEXTNAME_TOKEN=<Name of OOB Add on - exact match> YPACKAGE_TOKEN=<package structure from OOB Addon - exact match) YMANAGER_TOKEN=<Manager class from OOB Addon - exact match) YCLASSPREFIX_TOKEN=<Name of class prefix from extensioninfo.xml for OOB addon> YGENERATED_TOKEN=Generated
YEXTNAME_TOKEN=notificationoccaddon YPACKAGE_TOKEN=de.hybris.platform.notificationoccaddon YMANAGER_TOKEN=NotificationoccaddonManager YCLASSPREFIX_TOKEN=Notificationoccaddon YGENERATED_TOKEN=Generated
Final Step – Run extgen 🙂
Pretty much is done with above. Go to your platform and run ant extgen.
System will give you an option to select OOB addon to select as template, and will allow you to create a custom extension/addon using this template.
Your new extension name couldn’t have the exact substring match from parent extension. To avoid this, choose a name which doesn’t have the exact parent name in it.
Thank you for reading!