Create the Extension File

Now we’re going to create our step which adds the loyalty points.

To see if everything is working as expected we just add a static number of loyalty points for every products. Let’s say 100.

Let’s continue with the coding. As an input we get an array of products and as an output we need to return also an array of products. So our code needs to iterate through the products and add the loyaltly points.

It can look like this:

Phase 1
module.exports = async (context, input) => {
  const products = => {
    product.loyaltyPoints = 100
    return product
  return {'products': products}

Test (Run Local Environment)

Awesome! We’re done with our step so far. Let’s test it.

In the production system all steps run in an isolated container. This makes it difficult to develop and debug our code. To make it easy for us the SDK includes a special runtime which let us execute the step locally.

To start this runtime we need to do the following steps:

  1. Execute sgconnect extension attach to attach all extensions to the runtime
  2. Start the runtime with sgconnect backend start


In the production system the extension communicates with the Shopgate Connect platform via a high-performance channel. To emulate this communication the SDK contains a proxy. It can be called with a normal REST call to trigger a pipeline.

Let’s try it out. First of all we need to open a REST client. We recommend Postman.

For our test we need a category id. This can be different depending on the marketplace and the setup. In order to get a valid category we need to visit our Shopgate Merchant Admin and navigate to Products --> Categories. There we need to pick an active category and read out the Category number.

Set up the request:

  • Method: POST
  • URL: http://localhost:8090/pipelines/shopgate.catalog.getProducts.v1
  • Body-type: JSON (application/json)
  • Body: {“categoryId”:"[Insert the category number here]"}

Now we see the loyalty points in all products of the response.