you can write a custom extension as per your requirement that use or override existing extensions functionalities. You can create your own extension So every extension in hybris contains
Hybris provides an ant-based extension generator and provide extension templates for specific function. you can choose any one as per your requirement.
Ant extgen command can be used to create an extension. This command uses the specified extension template to create the structure of the new extension. We should not modify any of the existing extension in Hybris. We should always create new extension to define the custom logic in Hybris.
Extension generation Command :
ant extgen
Hybris provide following extension templates
yempty : structure for an extension with a core and web module. It is default extensions.
ycommercewebservices : for customize web services extension
ycockpit : for customize of cockpit functionalities
ybackoffice : for customize backoffice functionalities extension
yaddon : for customize for Accelerator AddOns
Create a new extension skeleton using ant extgen command
Specify the extension template, name of the extension and package name while running this command
After execute command with extension template will create the structure of the new extension.
we will be added as the name of the extension inside the extensioninfo.xml file. which make reference the new extension in the localextensions.xml file. So that hybris will consider this extension during the build.
Build the Hybris package .
Update localextensions.xml
<extensions><path dir="${HYBRIS_BIN_DIR}" depth="4" />
<!-- Add new ext -->
<extension name="myfirstextension" />
</extensions>
After that , you can start write to your business logic in extension.
Step by Step for new custom extension
for example: C:\HYBRIS-1808\hybris\bin\platform
Select yempty for the extension template
Enter the name of the extension. for example: myfirstextension
Enter the package prefix . for example: com.test.myfirstextension
{YourPath}/bin/custom/myfirstextension
C:\HYBRIS-1808\hybris\bin\custom\myfirstextension
open C:\HYBRIS-1808\hybris\config\localextensions.xml file and add new extension
<extension name="myfirstextension"/>
C:\HYBRIS-1808\hybris\bin\platform> ant clean all
C:\HYBRIS-1808\hybris\bin\platform> hybrisserver.bat
Default Login credential
user name : admin
password : nimda
search your extension "myfirstextension" and you will get your extension and webroot will be available for myfirstextension
myfirstextension/extensioninfo.xml
Comment <!--<webmodule jspcompile="false" webroot= "/myfirstextension"/> -->
Stop server (ctrl+c) and press y Run ant all and start server
Go to browser http://localhost:9001/hac and login again and Go to platform- >Extensions and check webroot for myfirstextension. it will be empty
Import the generated extension into your Eclipse and start work on new extension.
Dependencies on other extension
If an extension is dependent on other extensions then it should define those dependencies using requires-extenion tag. Every extension has own extensioninfo.xml file in which we need to add requires-extenion.
<requires-extenion name=”secondextension”>
<requires-extenion name=”thirdextension”>
Ant modulegen command can be used to create the module. It creates the set of extensions based on the module template we select. Generally for B2B and B2C module , it creates 7 extensions which are logically related and grouped.
<extension name='mycommercecore' />
<extension name='mycommercefacades' />
<extension name='mycommercestorefront' />
<extension name='mycommercecockpits' />
<extension name='mycommerceinitialdata' />
<extension name='mycommercefulfilmentprocess' />
<extension name='mycommercetest' />