Hybris – Generate addon from Another addon? (crack)

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

Sample

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.

NOTE :

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!

4180cookie-checkHybris – Generate addon from Another addon? (crack)

4 thoughts on “Hybris – Generate addon from Another addon? (crack)

  • I tried this on b2boccaddon and created a custom addon and this works.

    In b2boccaddon –
    added the tag

    Next created the extgen.properties , copied from yoccaddon into b2boccaddon

    Edited as follows (check the structure and details as mentioned in the articles – case and pattern matters ) ;

    YEXTNAME_TOKEN=b2boccaddon
    YPACKAGE_TOKEN=b2boccaddonpackage
    YMANAGER_TOKEN=B2boccAddonManager
    YCLASSPREFIX_TOKEN=B2boccaddon
    YGENERATED_TOKEN=Generated

    while doing ant extgen , you cannot have addon names which partly matched the template name, like myb2boccaddon.
    Use like myoccb2baddon instead.

    It will work

  • Yes Pradip, Glad it helped you.

    As mentioned in the NOTE section on this blog, you can not have the matching string in it’s name from the OOB addon, so you might need to consider taking a different name.

    “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.”

Leave a Reply

Your email address will not be published.