Fluent Commerce Logo
Docs
Sign In

Module Recipe - How to create an Extension Data Module

How-to Guide

Author:

Ankit Mehta

Changed on:

21 Mar 2025

Key Points

  • Describe the steps to create a new Data Module
  • Use B2C Sample data for reference
  • Build and Install the Extension Data Module

Steps

Step arrow right iconPrepare Extension Module

  • Change into the directory for the new module or create it
  • Create the new module by running
    `fluent module create -m <module-name>`

Step arrow right iconAdd the extension assets to the module

Next up is adding in the content.

  • First, update the version and any dependencies in
    `resources/module.json`
  • Update the assets in the
    `resources/`
    folder like 
    • adding locations data under the locations folder or 
    • adding required users data within the users folder and so on
  • You may refer to the B2C Sample data module to get the basic JSON structure of all the assets. The B2C Sample Data Module can be downloaded using the following command:

  • Once downloaded, unzip the
    `fcx-module-b2c-sample-data-x.x.x.zip`
    and refer to the sample data of the various assets. 

Step arrow right iconBuild the extension module

Now we're ready to build the extension module and create the Module Structure. Essentially this is a copy process, of the assets from the

`resources`
directory into a new
`dist`
directory. 

With modules that contain a plugin, this step includes compiling the rules, executing tests, creating the plugin.jar file and copying it over into the

`dist`
directory.

For convenience, the module template provides a build script in the

`scripts`
directory.

  • Execute
    `scripts/build_module.sh`
    - check out the options, for example
    `-x`
    to for verbose logging. As there is likely to be a plugin in this kind of module do not use option
    `-p`

Now the module is ready to be used. You can inspect it in the

`dist`
directory as either the Module Archive
`*.zip`
or the Module Structure in
`dist/<module-name>/`
.

Step arrow right iconInstall the Extension Module

Once the module has been built, it's time to deploy it or in module jargon, install it.

If the workflow (or module) requires configuration, like network refs or catalogue refs, then you need to create a config file first:

  • Perform a
    `fluent module config dist/<module-name>-<version>/`
    or
    `fluent module config dist/<module-name>-<version>.zip`
    and use the config file in the subsequent module install command. For an example of the full command including profile and retailer parameters please see here
  • Update the newly generated module.config.*.json with the config parameters

Finally, install the module:

  • Run
    `fluent module install dist/<module-name>-<version>/`
     or
    `fluent module install dist/<module-name>-<version>.zip --config module.config.*.json `

    For an example of the full command including profile, retailer and config file parameters please see here

Note, that for clarity in this example, we omitted the required parameters for the profile and retailer.

Remember, you can install a module from its Module Structure or the Module Archive. The install command automatically unpacks an archive if needed.