Creating a Customized B2B Accelerator with Modulegen
Learn how to use the modulegen tool to create a customized SAP Hybris Commerce B2B Accelerator.
The modulegen tool is delivered with SAP Hybris Commerce and can be used to generate sets of dependent extensions to quickly start new projects or create new applications. The modules shipped with SAP Hybris Commerce help you to meet client requirements from the very beginning by allowing you to generate fully functional applications that can then be customized. The modulegen tool replaces the schema, package name, extension class prefixes, and some other properties across a set of extensions, all while maintaining the relationships between them. The tool is run as an ant task, so it requires the ant libraries to be present on the system.
SAP Hybris Commerce ships with an extension generator tool called extgen, which is short for extension generator. Using the extgen tool, you can create new extensions based on extension templates. With the extgen tool, you can create one new extension using one template extension. The modulegen tool is a wrapper around the extgen tool that allows you to create a set of extensions from a set of template extensions. From a technical perspective, any extension can be used as a template extension. The extgen tool is fairly basic in that it simply replaces the tokens configured in a properties file.
Tip Some extensions only work as a set, such as the majority of the Accelerator extensions. These extensions should be created using the modulegen tool so that you can generate them together as a set. On the other hand, some extensions make sense as stand-alone extensions, and that is when you would use the extgen tool.- <HYBRIS_HOME> to refer to the directory where you unzipped the SAP Hybris Commerce package.
- <COMMON_FOLDER> to refer to the directory where the <HYBRIS_HOME> folder is extracted.
- <HYBRIS_BIN_DIR> to refer to the directory that contains all the SAP Hybris Commerce extensions, as well as the platform directory.
Prerequisites
Before running the modulegen tool, you need to download the latest version of SAP Hybris Commerce. See Download for more details.
Once you have downloaded SAP Hybris Commerce, extract the Hybris Commerce ZIP file in <{COMMON_FOLDER}>.
Tip If you are in a training class, the Hybris Commerce ZIP file will be provided by your trainer.Creating a Customized B2B Accelerator
The following procedure describes how to create a customized B2B Accelerator using the B2C Accelerator installation recipe.
Note Alternatively, you can use the b2b_acc recipe to install B2B Accelerator, but it offers limited customization. The following procedure has more customization flexibility and uses the b2c_acc recipe as a base, and then adds the required B2B components.-
Navigate to the <HYBRIS_HOME>/installer directory.
-
Invoke the Installer with the b2c_acc recipe by entering the following command:
- On Windows:install.bat -r b2c_acc
- On Linux or Mac:./install.sh -r b2c_acc
-
Navigate to the <HYBRIS_BIN_DIR>/platform directory.
-
Set yourantenvironment by entering the following command:
- On Windows:setantenv.bat
- On Linux or Mac:. ./setantenv.sh
-
Run theant modulegencommand and modify theinput.nameandinput.packageparameters as required, for example:
ant modulegen -Dinput.module=accelerator -Dinput.name=training -Dinput.package=de.hybris.training -Dinput.template=develop
Where:
- input.moduleparameter: Configures the modulegen task to use the accelerator module.
- input.namevalue: Indicates the prefix that is added to the new extensions generated by modulegen.
- input.packagevalue: Defines the default Java package prefix.
- input.templateparameter: Defines how to use the default Hybris configuration.
- After running theant modulegencommand, open the localextensions.xml file located in <HYBRIS_HOME>/hybris/config folder.
-
Add the new extensions generated by modulegen to the localextensions.xml file. The exact XML snippet to add is displayed in your console output. The following is an example:
trainingcore trainingfacades trainingstorefront traininginitialdata trainingtest trainingcockpits trainingfulfilmentprocess
-
As instructed in the console output, remove any of the following extensions that might appear in your localextensions.xml file:
yacceleratorcore yacceleratorfacades yacceleratorstorefront yacceleratorinitialdata yacceleratortest yacceleratorcockpits yacceleratorfulfilmentproces
-
Add the following B2B Accelerator extensions to the localextensions.xml file:
<extension name='powertoolsstore' /> <extension name='b2bcommercebackoffice' /> <extension name='b2badmincockpit' /> <extension name='b2bacceleratoraddon' /> <extension name='commerceorgaddon' />
-
Install the B2B Accelerator AddOns on the training storefront by running the followingantcommands from the <HYBRIS_BIN_DIR>/platform folder:Note
ant addoninstall -Daddonnames="b2bacceleratoraddon" -DaddonStorefront.yacceleratorstorefront="trainingstorefront" ant addoninstall -Daddonnames="commerceorgaddon" -DaddonStorefront.yacceleratorstorefront="trainingstorefront"
More AddOns can be added to your custom storefront. For each additional AddOn, you must add an entry to the localextentions.xml file and run the correspondingant addoninstallcommand. The extensions most commonly used in advanced B2B Accelerator set-ups include the following: -
Add the following properties to <HYBRIS_HOME>/hybris/config/local.properties file:
website.powertools.http=http://powertools.local:9001/trainingstorefront website.powertools.https=https://powertools.local:9002/trainingstorefront
-
Build and initialize Hybris Commerce by running the followingantcommand from the <HYBRIS_BIN_DIR>/platform folder:
ant initialize
-
Start the Hybris server by running the following command from the <HYBRIS_BIN_DIR>/platform folder:
- On Windows:hybrisserver.bat
- On Linux or Mac:./hybrisserver.sh
For more options on starting and stopping the Hybris server, see Running SAP Hybris Commerce.
-
Once the server is started, ensure the B2B Accelerator powertools storefront is working by loading the following URL: https://powertools.local:9002/trainingstorefront/powertools/en/USD.
For the above URL to work, you must have the following entry in your computer's hosts file:127.0.0.1 powertools.local
Configuring the local.properties File for a Different Database
If you do not want to use the default HSQL database that is shipped with the SAP Hybris Commerce, you can set up a different database.
For example, to set up a MySQL database, add the following properties to the local.properties file:
db.url=jdbc:mysql://localhost/training?useConfigs=maxPerformance&characterEncoding=utf8 db.driver=com.mysql.jdbc.Driver db.username=your_username db.password=your_password db.tableprefix= mysql.optional.tabledefs=CHARSET=utf8 COLLATE=utf8_bin mysql.tabletype=InnoDB
Note that the MySQL JDBC driver is not included with Hybris Commerce. The driver can be downloaded from this MySQL page: http://dev.mysql.com/downloads/connector/j/.
Once you have downloaded the driver, unpack and copy the mysql-connector-java-X.X.XX-bin.jar file to the <{HYBRIS_HOME}>/hybris/bin/platform/lib/dbdriver folder.