Pages - Menu

Demandware - Implementing 3rd party FTP Service for XML Drop


I developed a few Demandware cartridges that export xml via ftp for 3rd party integration. A few things that I have done such as:-

  • Piggy back a ftp drop task to the current job schedule that imports xml from a difference integration point
  • Using standard Demandware pipelet to generate a xml feed for ftp drop
  • Create a custom script node to generate a xml feed for ftp drop
It wasn't too difficult as a job, but I found a few hidden gotchas that I believe are noteworthy.

We are dealing with the latest Demandware version 16.7.


FTP Constraints

  • Ftp connection is established using passive transfer mode (PASV) only.
  • Demandware only support ftp and sftp for backend integration, no ftps.
  • Use FTPClient for ftp; and SFTPClient for sftp.


In our code, we use dw.util.ArrayList to filter out products for export. We ran into an error where the ArrayList cannot be bigger than 20,000 in size.

Front End Debugging

I was testing out a pipeline-startnode by direct url from a broswer, it did not turn out well because some of the pipelets can only be executed from the backend. The error message looks like this.

Limit for quota 'api.pipelet.ImportExport' exceeded. Limit is 0, actual is 1.

Job Schedule

We tried to schedule a job for our cartridge and learnt in a hard way that JS Controller is not supported for Business Manager Job Schedule. Only pipeplines can be used.

Traversing XML

If you happened in need of traversaing the xml, Demandware uses ECMA scripts for XML. Here is a quick start guide.


Besides the firewall rules that I needed to manage with our external vendor, we also need to request outbound firewall rule from Demandware.

As they pointed out in their doc, "Before you can make an outbound FTP connection, the FTP server IP address must be enabled for outbound traffic at the Demandware firewall for your POD. Please file a support request to request a new firewall rule".

From Demandware, there are steps to request a Firewall rule to allow outgoing connections to 3rd party services.

Demandware - Monogram by using Product Options


Our business wants to start selling personalized product by monogramming. In this particular promotion, customer gets a free monogrammed luggage tag when they buy a bag.


In Demandware, this can be achieved by using Product Options. This is the recommended way to deal with monogram in Demandware. As they stated in their document, "product options enable you to sell configurable products that have optional accessories, upgrades...".

We can set up product options by going into Business Manager. Merchant Tools -> Products and Catalogs -> Product Options.

Create a New Option and put in relevant details.

In our scenario, we have allowed up to 3 initials for our monogram. Due to Demandware limitations and our UI design, we decided to store the values in 3 different product options. Each option stores A-Z and a blank, it can vary base on your technical and UI requirement.

We will then create the System Object Attribute to store the Product Options.

In Administration -> Site Development -> System Object Types, we will add new attributes for Product.


Monogramming options can be set at per color level. Therefore, in our product detail page, we are now able to sell our chocolate color bag with monogramming options but not our black color bag.

And the monogram information is available in our mini cart, cart, checkout and all the way through to our order summary page, as well as the order confirmation email that we sent to our customers.


There were a few discussions, considerations and research done within our team when we were planning for the monogram features for our products. Once we read enough Demandware documentations, and with a few try and error in our sandbox, we got our solution. We are happy with this implementations because it uses the native Demandware features rather than putting custom code in our cartridge.

Demandware - Get Active and Upcoming Promotions


We are trying to get a collection of promotions that are either active or upcoming. We want to pre-calculate all our promotional price in advance for our affiliate feeds, so they will get the most updated price without frequent feeds from us.

At the time of writing, we are using the latest DemandWare 16.7 API.


In the DemandWare API, there is no such thing about getting active and upcoming promotions. Ideally we would like to return a collection combining the following.


Since these 2 methods return an object PromotionPlan and there is no supporting methods such as promotionPlanA.Add(promotionPlanB), so we will need to write a bit more code to achieve what we want.

function getActiveAndUpcomingPromotions() : Collection
 var promos = PromotionMgr.getPromotions().iterator();
 var result : ArrayList = new ArrayList();
 var now : Date = new Date();
 while (promos.hasNext())
  var promo =;
  if ( 
  || (promo.startDate != null 
    && promo.startDate > now 
    && (promo.endDate == null || promo.endDate > now)))
 return result;


  • Depending on number of promotions in the system, this can be an expensive operation to loop through all the promotions, so it is recommended to use local caching for the collection.
  • Our custom code is better than the original PromotionMgr.getUpcomingPromotions(previewTime : Number) because it was not possible to retrieve ALL future promotions where the previewTime is compulsory.
  • Our custom code only return Collection of Promotion, this is not the same as a PromotionPlan.
  • Beware of the ArraySize Limit 20,000 in DemandWare. Pushing more than 20,000 active promotions to the array will throw exception.