Demandware Student Guide Did PDF Book Software 12.6
Demandware Student Guide Did PDF Book Software 12.6
Student Guide
Version 12.6
Trademarks & Copyright Acknowledgements
Demandware® is a registered trademark of Demandware Inc.
Corporate Headquarters
United States
5 Wall St., Burlington, MA 01803 USA
Email: [email protected]
Phone: +1 (888) 553 9216
EMEA Offices
Benelux & Nordics
Newtonlaan 115
3584 BH Utrecht
The Netherlands
Email: [email protected]
France
54/56, avenue Hoche, 75008
Paris, France
Email: [email protected]
Germany
Landsberger Strasse 155/2, 80687 München, Germany
Leutragraben 2-4, 07743 Jena, Germany
Email: [email protected]
Corporate Sites
External site: http://www.demandware.com
XChange Community: https://xchange.demandware.com
Documentation: https://documentation.demandware.com
Page 2
Instructor Guide Table of Contents
Table of Contents
INTRODUCTORY MATERIAL
Getting Started 7
MODULES
Demandware Architecture 12
Review 26
UX Studio Overview 28
Overview 29
Creating a Workspace 30
Creating a Server Connection 33
What is a Cartridge? 48
Cartridge Types 51
Page 3
Instructor Guide Table of Contents
Pipeline Elements 60
Creating a Pipeline 62
Executing a Pipeline 68
Call Nodes & End Nodes 72
Jump Nodes 77
The Pipeline Dictionary 78
Troubleshooting with the Request Log Tool 70
ISML Templates 95
Overview 131
API Packages 133
Page 4
Instructor Guide Table of Contents
Overview 152
XML Metadata File 154
Overview 214
Using the Storefront Toolkit: Page Information 215
Page 5
Instructor Guide Table of Contents
Page 6
Instructor Guide Getting Started
Getting Started
Page 7
Instructor Guide Getting Started
IMPORTANT NOTE
You may also occasionally find important notes such as this one in
the text of this guide. These shaded boxes provide particularly
important information in an attention-getting format.
Page 8
Instructor Guide Getting Started
Module Blocks
Lesson Blocks
Page 9
Instructor Guide Getting Started
Learning Objectives
After completing this program, participants will be able to:
Deconstruct SiteGenesis
Program Timing
This course is designed to take 4 days of instruction with 1 half-day
of review and testing, followed by a certification exam.
Number of Participants
For on-site delivery and one instructor, the maximum number of
participants should not exceed 15.
Page 10
Instructor Guide Getting Started
Program Preparation
Pre-Work
Prior to beginning this course, each student is required to do the
following:
Required Materials
Every student must have a personal laptop or desktop with
administrator rights.
Every student must have a printed copy of the Developing in
Demandware Student Guide.
Room Set-Up
For on-site course delivery:
Instructor Preparation
Prior to delivering this course:
Print out and ship a student guide for each student to the
on-site location.
Page 11
Instructor Guide Demandware Architecture
Demandware Architecture
Goal
This module is intended to give you an overview of the
Demandware SaaS Platform Architecture.
Time
1.5 Hours
Overview
We will discuss Software as a Service, Demandware Realms,
Primary Instance Groups and SiteGenesis, the reference storefront
application. We will also create a new empty site, import a copy of
SiteGenesis into a site, and configure the settings for the imported
site.
Materials Needed
Each student will need a training sandbox instance and a login for
it.
Page 12
Instructor Guide Demandware Architecture
Page 13
Instructor Guide Demandware Architecture
Page 14
Instructor Guide Demandware Architecture
Content
Marketing campaigns
Search settings
Customers
Site Analytics
Site URL’s
Site Preferences
Page 15
Instructor Guide Demandware Architecture
Code Versioning
Site Development
Data Import/Export
Page 16
Instructor Guide Demandware Architecture
Page 17
Instructor Guide Demandware Architecture
11. Click the Storefront link on the left. A browser window will open
up to the storefront URL:
Page 18
Instructor Guide Demandware Architecture
Page 19
Instructor Guide Demandware Architecture
Page 20
Instructor Guide Demandware Architecture
You can import the SiteGenesis Demo Site below or click the
Browse… button to retrieve another file from your hard drive,
followed by the Upload button.
You will be asked:
Click Ok.
You can view the status of the import in the Status section of
the page.
When your import is finished, you will see the new site listed in
Business Manager. You will also receive an email that the job is
complete.
b. Import remotely:
Select the Remote radio button.
Enter all required data for accessing the remote server account:
Page 21
Instructor Guide Demandware Architecture
d. Click Ok.
e. You can view the status of the import in the Status section of the
page.
5. When your import is finished, you will see the new site listed in
Business Manager. You will also receive an email that the job is
complete.
Page 22
Instructor Guide Demandware Architecture
Site Configuration
After you have imported the SiteGenesis site, you will need to disable
site caching in order to see your code changes immediately in the site.
This is something that developers do in their sandboxes to avoid
having the page cache take effect and prevent pages from displaying
differently after they have made code changes. In production
instances the cache is on by default.
You will also need to index the site in order to be able to search for
products from the storefront.
3. Set the Time to live value to zero and uncheck the Enable page
caching setting.
Page 23
Instructor Guide Demandware Architecture
Page 24
Instructor Guide Demandware Architecture
5. Click Apply Index Settings at the bottom of the table: this will
ensure that indexing occurs automatically after any changes that
require it.
6. Use Training Products and Catalogs Products to find the
Page 25
Instructor Guide Demandware Architecture
P0048 product.
7. Lock the product so it can be edited.
8. Locate the site attribute Online/Offline and set it to No for the
Training Site only:
9. Apply your changes and verify that the product is not available on
the Training site. You might have to wait for incremental indexing
to complete.
Review
Question True False
Page 26
Instructor Guide Demandware Architecture
Enter item number from Column B that matches the item in Column A
Column A Column B
Page 27
Instructor Guide UX Studio Overview
UX Studio Overview
Goal
The purpose and goal of this module is to perform common tasks
with UX Studio.
Time
1.5 Hours
Overview
We will demonstrate how to create a new workspace, server
connection, and getting around the user interface.
Materials Needed
All course solutions cartridges from the instructor sandbox: solutions,
int_simplefeeds, test_simplefeeds, etc.
Page 28
Instructor Guide UX Studio Overview
Overview
Introduction
UX Studio is an Integrated Development Environment (IDE) used for
programming in the Demandware platform.
Page 29
Instructor Guide UX Studio Overview
Creating a Workspace
Introduction
A workspace is an Eclipse-specific local directory that contains Eclipse
projects. Normally Eclipse projects are connected to Java source
directories (packages). In Demandware Studio projects are different:
they either define a connection to a Demandware instance or they point
to a Demandware cartridge. They are never used to compile Java
projects since Java code is not used in Demandware application
programming.
Each workspace should have only 1 Demandware server connection
(covered later in this module). For example, if you are a developer
working on numerous client projects, you will want to create a separate
workspace for each client. Each client workspace will then have only 1
specific server connection.
2. Eclipse will first display the Welcome message in the main working
area.
Page 30
Instructor Guide UX Studio Overview
Creating a Workspace
Page 31
Instructor Guide UX Studio Overview
Creating a Workspace
If you already have a workspace and need to create a new one, follow
these steps:
1. From the main menu in UX Studio, click on FileSwitch
WorkspaceOther…
Page 32
Instructor Guide UX Studio Overview
Page 33
Instructor Guide UX Studio Overview
3. Click Next.
4. A security warning regarding an invalid certificate for your
sandbox shows up. Click Yes to continue.
5. Select version1 as the target version you want to upload your files
to:
6. Click Finish.
Your connection project is now connected to your sandbox and will
be used to upload any cartridge projects to that sandbox, as seen later
in this module.
Page 34
Instructor Guide UX Studio Overview
Page 35
Instructor Guide UX Studio Overview
Page 36
Instructor Guide UX Studio Overview
6. Click ‘Next’.
7. In the next window, click to ‘Browse…’ button.
8. Locate the folder on your hard drive where cartridges are located.
Your instructor will provide a zip file with all solution cartridges
for you to install locally. Click OK.
Page 37
Instructor Guide UX Studio Overview
12. If you intend to upload the imported cartridges to the active server
(why not?), click Yes. Otherwise the cartridges will reside in your
workspace but will not be uploaded automatically when you make
changes.
13. The next dialog allows you to select the specific cartridges you
want uploaded to your server connection. Click Select All.
Page 38
Instructor Guide UX Studio Overview
14. Click OK to upload the cartridges and finish the import process.
15. You might receive a dialog stating to delete projects on the server
not matching the ones in your workspace.
If you’re the only one working on that instance e.g. it’s your
personal sandbox you might recognize the projects there.
If you are working on a collaborative instance consult first with
your colleagues !
Page 39
Instructor Guide UX Studio Overview
17. Select Project References and then select every cartridge that you
want uploaded to the server connection:
Page 40
Instructor Guide UX Studio Overview
Demandware Views
Introduction
The Demandware UX Studio plug-in gives you access to specific
Demandware programming files. Those files are sorted and given
their own custom views in the application.
The primary files as you see listed above, are Cartridges, Pipelines,
Pipelets, Templates, and Scripts (we will discuss each file type in
greater detail later in this course.) For example, to view all Pipelines
in a workspace, you only need to click on the ‘Pipelines’ tab.
As you can see from the screenshot below, you will have the ability to
filter the results by typing in the first few letters of the file name you
are searching for:
Page 41
Instructor Guide UX Studio Overview
Demandware Views
To view the file path for a file, click on the Show/Hide Resource Part
icon:
The Navigation tab will allow you to view all files in your workspace
in a tree view structure. It also allows common tasks like copy/paste,
file comparisons, etc.
Page 42
Instructor Guide UX Studio Overview
4. Scripts
5. Pipelines
6. Navigator
Do not go into deep detail of each file type. Just discuss what file
types are in each view and how to search for a file in the search
box.
Page 43
Instructor Guide UX Studio Overview
For those developers who have been using Eclipse for development,
you may skip this topic since you most likely will have already
utilized the search capabilities of the application.
4. Enter any file name patterns you want to filter by in the ‘File name
patterns’ field.
5. When you are ready, click the ‘Search’ button. Your results will be
displayed in the ‘Search’ box.
Page 44
Instructor Guide UX Studio Overview
Page 45
Instructor Guide UX Studio Overview
Review
Question Answer
d) Clicking on EditFind
Transition to Cartridges
Page 46
Instructor Guide Cartridges
Cartridges
Goal
The purpose and goal of this module is to familiarize you with
Demandware cartridges.
Time
1.5 Hours
Overview
We will discuss what a cartridge is, cartridge directory structure,
the cartridge path in Business Manager, and we will demonstrate
how to create an empty cartridge as well as a new storefront
cartridge.
Materials Needed
N/A
Page 47
Instructor Guide Cartridges
What is a Cartridge?
Introduction
A cartridge is a directory structure that is used as a flexible
deployment mechanism for customized functionality. A cartridge can
contain many different types of files: static files such as CSS,
Javascript, and images, as well as WSDL files. There are also folders
for Demandware specific files: pipelines, scripts, templates, and form
definitions.
A cartridge is fully contained in one directory. Every cartridge has
specific sub-directories where certain file-types must be stored. For
instance, all Demandware script files must be stored in a scripts
folder.
When a call is made to a file, the Demandware server will look for the
file starting with the first cartridge listed in the cartridge path. For
instance, if a call is made to an ISML file called product.isml and that
file is located in two cartridges that are both in the cartridge path, the
Demandware server will use the first one it finds.
Page 48
Instructor Guide Cartridges
What is a Cartridge?
Run the Add Cartridge in Cartridge Path activity.
Walk the students through adding the storefront cartridge to the
cartridge path.
Page 49
Instructor Guide Cartridges
What is a Cartridge?
6. Click on the Settings tab.
Page 50
Instructor Guide Cartridges
Cartridge Types
Introduction
There are three types of cartridges you can create in UX Studio:
1. Demandware cartridge
2. Storefront cartridge
3. Business Manager cartridge (not covered in this course)
Your business needs will determine what type of cartridge you will
create in UX Studio. Every new customer will have at least one
storefront cartridge.
Storefront Cartridge
A new storefront cartridge contains a copy of the default SiteGenesis
cartridge available in the SiteGenesis Demo Site package. Most
projects start with this SiteGenesis reference code.
Demandware Cartridges
If you need to build re-usable functionality that is specific to a site
when there are multiple sites in a production instance, then you may
need to create a new cartridge.
You may want to add a new cartridge when functionality is:
Use another storefront cartridge for common code that you intend
to reuse in multiple sites: <client>_core
Page 51
Instructor Guide Cartridges
Cartridge Types
Run the Viewing WebDAV Cartridge Directory activity.
Walk the students through viewing cartridge contents on a
Demandware instance through Business Manager.
5. Click OK.
6. Click on the link for the code version you wish to view:
Page 52
Instructor Guide Cartridges
Cartridge Types
Run the Create a New Server Version activity.
Walk the students through creating a new version in the server, and
uploading cartridges to that version.
Page 53
Instructor Guide Cartridges
Cartridge Types
6. Select version2 from the dropdown:
Page 54
Instructor Guide Cartridges
4. Click Finish.
5. Examine the training cartridge. Notice that the directory structure
was created but there are no files.
Page 55
Instructor Guide Cartridges
1) Core Cartridge
This cartridge will embody the business layer and contain all of the
“server” side components such as Pipelines and Demandware Scripts
as well as a non-javascript version of the storefront. This cartridge will
embody the simple presentation layer and contain ISML templates,
Common CSS files, Forms and Resource files. There will be no use of
JavaScript, AJAX, or any advanced UI elements inside of this
cartridge. As a result the rendering output of Core is just a stream of
HTML & CSS assets that represent the page styled to look as close as
possible to Site Genesis wireframes today without the use of
JavaScript. So at this level the site will be “usable”, and only partially
visually esthetic. The goal of this cartridge is to provide a
fundamental starting point for new site development under the
circumstances when the client’s design differs significantly from Site
Genesis’ wireframes. The benefit being that you can start with just the
essentials and not have to “undo” or “separate” any pre-conceived
Site Genesis UI design.
2) Rich UI Cartridge
This cartridge will hold the overloaded any specific CSS and advanced
UI elements required to turn the Core Cartridge into the advanced
look and feel of the Site Genesis storefront as we know it today. That
being said, it is important that Rich UI Cartridge does not contain
ISML templates, but rather uses an initialization mechanism, in order
to effect changes to the rendering of Core templates in the client
browser.
Page 56
Instructor Guide Cartridges
3. Click Finish.
Page 57
Instructor Guide Cartridges
Transition to Pipelines
Page 58
Instructor Guide Pipelines
Pipelines
Goal
The purpose and goal of this module is to familiarize you with
Demandware pipelines and pipeline nodes.
Time
2.5 Hours
Overview
We will discuss what a pipeline is, the pipeline dictionary, as well
as the different pipeline elements in a pipeline. We will also
demonstrate how to use the following elements: start, interaction,
call, jump, and pipelets.
Materials Needed
Solutions Cartridge
Page 59
Instructor Guide Pipelines
Pipeline Elements
Introduction
A pipeline is a logical model of a particular business process, similar
to a flowchart. Demandware UX Studio provides a visual
representation of the process within the Eclipse IDE. Below is the
Product-Show pipeline that renders the product detail page on the
SiteGenesis site:
Pipelines are stored in XML files in the file system, both locally on
your PC and on the server. Pipelines are defined and stored within the
context of a cartridge.
Page 60
Instructor Guide Pipelines
Pipeline Elements
When the storefront application attempts to reference a pipeline in a
cartridge, it searches for the pipeline in the cartridge's path and uses
the first one it finds. In other words, when a pipeline with the same
name exists on two cartridges, the first one found in the path is used.
Therefore, it is best to use unique pipeline names to ensure that the
framework locates the correct pipeline.
Page 61
Instructor Guide Pipelines
Pipeline Elements
Stop Node Used to terminate a sub-pipeline and calling
pipelines, stops execution immediately. Used
in pipelines that execute a batch job.
Creating a Pipeline
Introduction
In order to create a new pipeline, you will need at least one Start node
and one Interaction Node. When creating a new pipeline in Studio,
the pipeline palette will be available in the Pipeline Editor, as shown
below.
If you do not see the palette when you create a new pipeline, be sure
to click the button on the upper-right corner of the editor to open it
up.
Page 62
Instructor Guide Pipelines
Pipeline Elements
Start Nodes
A pipeline may have multiple Start nodes but each node must have a
unique name. Every Start node is the beginning of a different logical
branch within the pipeline.
Configuration properties include:
1. Name: Used in pipeline calls
2. Call mode: Specifies the accessibility of the pipeline from a
browser.
a. Public: Can be called from the browser or from another
pipeline
b. Private: Can be called from another pipeline via Call or Jump
Nodes
3. Secure Connection Required:
a. False: Pipeline can be invoked with HTTP and HTTPS
protocols
b. True: Start node can only be accessed via secure (HTTPS)
protocol.
Interaction Node
Specifies the template to display on the browser. If Dynamic
Template is:
1. true: Template Expression must be a variable containing a
template name. The template to be called by an interaction node is
not always hard-coded in the node. Instead, the name can be
determined dynamically during runtime from the Pipeline
Dictionary.
2. false: Template Expression contains path to template under
templates/default/folder
Page 63
Instructor Guide Pipelines
Pipeline Elements
Transition Node
The transition node creates a transition between two nodes. You can
easily create a transition between two nodes by clicking and dragging
your mouse between two nodes in a pipeline.
Page 64
Instructor Guide Pipelines
Pipeline Elements
Page 65
Instructor Guide Pipelines
Pipeline Elements
7. Click the Interaction node twice (not double-click) to get the
ellipsis button next to the node.
8. Click the ellipsis button to select the template you wish to display
with the Interaction node.
9. Select the template then click Ok.
10. Save the pipeline: CTRL+S.
Page 66
Instructor Guide Pipelines
3. Name the pipeline Hello, do not specify a group, and keep View
as the pipeline type.
4. Using the palette, drag a start node onto the pipeline editor. The
name defaults to Start.
5. Drag an Interaction Node below the start node, and connect them
with a Transition.
6. Create a template hello.isml that renders a simple HTML page
with a “Hello World!” greeting:
<html>
<head>
<title>Hello</title>
</head>
<body>
Hello World!
</body>
</html>
7. Specify template name hello.isml in the properties of the
Interaction Node in the pipeline.
8. Double-click the interaction node to verify that it opens the
hello.isml template.
9. Save both the pipeline and the template.
Page 67
Instructor Guide Pipelines
Executing a Pipeline
Introduction
Pipelines can be executed from the browser via an HTTP(S) request or
via Call or Jump Nodes. If the pipeline Start node is set as ‘Private’ it
can only be called via a Call or Jump node.
Calling a pipeline via a HTTP request requires the pipeline name and
start node at the end of the storefront URL:
http://instance.realm.client.demandware.net/on/demandware.store/
Sites-YourSite-Site/default
You can also pass parameters via HTTP requests using the following
syntax:
Page 68
Instructor Guide Pipelines
Executing a Pipeline
Executing a Pipeline Exercise
1. Test your pipeline in the storefront:
Page 69
Instructor Guide Pipelines
When looking at the request log, you can see the error is “Start node
not found (Start)”
Page 70
Instructor Guide Pipelines
4. The Request Log window will open. You may see a login screen
instead of the actual request log. If so, type in your Business
Manager login credentials, close the window, and repeat steps 2-3
here.
Page 71
Instructor Guide Pipelines
End Nodes
An End node finishes the execution of the called sub- pipeline and
returns a value equal to the End node name. This name must be
unique within the sub-pipeline and it may be used by the calling
pipeline to control flow after the call.
After the call, a transition from the Call node with the same name as
the returned value is followed. In the picture below, if the
Page 72
Instructor Guide Pipelines
4. Select the pipeline and start node you want to call using the Call
node.
5. From the Called Pipeline window, select Show Pipelines from the
Page 73
Instructor Guide Pipelines
6. Click Ok.
7. You will need to add Interaction nodes that will display the proper
isml template depending on which value is returned by the called
pipeline.
8. Name the transition nodes from the Call node according to the
values returned by the End nodes in the called pipeline.
9. Save your files then test your work by calling the Pipeline-Start
node from your storefront.
Page 74
Instructor Guide Pipelines
Page 75
Instructor Guide Pipelines
10. Create two templates that display different messages and assign
them to the Interaction nodes.
11. Save your work.
12. Invoke the Call-Start pipeline from your SiteGenesis site using
the URL query string param=1234
Page 76
Instructor Guide Pipelines
Jump Nodes
Introduction
A Jump node invokes a specified sub-pipeline. After the sub-
pipeline’s execution the workflow does not return to the calling
pipeline. It is the responsibility if the sub-pipeline to complete the
task and.
A jump node requires:
Page 77
Instructor Guide Pipelines
CurrentDomain
CurrentOrganization
CurrentPageMetadata
CurrentSession
CurrentRequest
CurrentUser
CurrentHttpParameterMap
CurrentForms
CurrentCustomer
CurrentVersion
Page 78
Instructor Guide Pipelines
Page 79
Instructor Guide Pipelines
Pipeline Debugger
The Pipeline Debugger operates on the pipeline level, not at
source code level. The Debugger allows for step-by-step tracking
of pipeline execution and for examining the pipeline dictionary at
runtime.
Page 80
Instructor Guide Pipelines
Page 81
Instructor Guide Pipelines
5. Click the Select button from the Site to Debug section. Select
the site you wish to debug then click the OK button:
Page 82
Instructor Guide Pipelines
Page 83
Instructor Guide Pipelines
Page 84
Instructor Guide Pipelines
Page 85
Instructor Guide Pipelines
Debugger Exercise
1. Create a pipeline debug configuration called SG Pipeline
Debug.
2. Add a breakpoint on the Call-Start pipeline.
3. From the storefront, invoke the pipeline.
Page 86
Instructor Guide Pipelines
Pipelets
Introduction
Now that we have introduced you to the pipeline dictionary, let’s
start using it to print information to a page using Pipelets.
A pipelet executes an individual business function within a
Demandware pipeline. Pipelets are pre-coded pieces of functionality
provided by Demandware but you can also use other types of
pipelets from the palette such as:
Page 87
Instructor Guide Pipelines
Pipelets, continued
To access and use a Demandware API pipelet, follow these steps:
1. In Studio, open or create the pipeline you wish to add a pipelet to.
2. Open the pipelet view tab.
3. From the pipelet view tab, drag and drop the pipelet onto the
transition node between the two nodes you want the pipelet to
execute. Be sure the transition node turns red when you hover
your mouse over it. Otherwise the pipelet will not be connected to
the node.
Page 88
Instructor Guide Pipelines
Pipelets, continued
4. Depending on the pipelet you are using, you will need to configure
the pipelet for execution in the properties tab of the pipelet. In the
example below, a GetProduct pipelet is used to create a product
object by using a ProductID value. The value for the input will come
from a stored variable in the pipeline dictionary. The product object
output will need a name value.
Undeclared values
Declared values
5. Save your pipeline.
Page 89
Instructor Guide Pipelines
Pipelets, continued
Pipelet Exercise
1. Create a new pipeline called ShowProduct. Add a Start node
connected to an Interaction node.
2. In the Pipelet API (use Studio Help), study the usage, input and
output parameters for the Catalog ⇒ GetProduct pipelet.
3. Drag and drop the GetProduct pipelet between the Start node and
Interaction node. Save your pipeline.
4. In Studio, verify that your debugging session is still active, and start
a new one if necessary.
Page 90
Instructor Guide Pipelines
Pipelets, continued
Save the hello.isml template as a new template product.isml in your
cartridge.
17. In the template for the successful case, show the product name using
the Product object found in the pipeline dictionary:
<h1>The product name is ${pdict.Product.name}</h1>
Page 91
Instructor Guide Pipelines
d) B or C
a) GlobalDefault
b) CurrentHttpParameterTable, CurrentScope,
CurrentRequest, CurrentForms, CurrentPipeline
c) CurrentHttpParameterMap, CurrentSession,
CurrentRequest, CurrentForms, CurrentCustomer
d) CurrentCustomer, CurrentSession, CurrentRequestor,
CurrentFormValue, CurrentHTTParameterMap
Page 92
Instructor Guide Pipelines
Page 93
Instructor Guide Internet Store Markup Language (ISML)
Goal
The purpose and goal of this module is to teach you the most
commonly used Internet Store Markup Language (ISML) tags and
expressions.
Time
4 Hours
Overview
We will define and give examples of using the following ISML
tags: <isset>, <isinclude>, <isdecorate>, <isloop>, <ismodule> and
<isif> tags.
Materials Needed
Solutions cartridge
Page 94
Instructor Guide Internet Store Markup Language (ISML)
ISML Templates
Introduction
Internet Store Markup Language or ISML templates are files with an
extension of .isml which define how data, tags and page markup are
transformed into HTML that is sent to the browser, using Cascading
Style Sheets (CSS) for page layout and styling.
The Demandware platform uses templates to generate dynamic
HTML-based Web pages for responses sent back to the client.
Templates are created using Internet Store Markup Language (ISML)
tags and expressions.
Page 95
Instructor Guide Internet Store Markup Language (ISML)
ISML Templates
5. Enter a name for your template in the Template Name box. There
is no need to type the .isml extension.
6. Click the Finish button.
7. Your new template opens in the ISML editor in UX Studio:
Page 96
Instructor Guide Internet Store Markup Language (ISML)
Page 97
Instructor Guide Internet Store Markup Language (ISML)
ISML Templates
<ismodule> Declares a custom tag
ISML Expressions
ISML Expressions are based on the Demandware Script language.
Since Demandware Script implements the ECMAScript standard,
access to variables, methods and objects is the same as using
JavaScript.
Page 98
Instructor Guide Internet Store Markup Language (ISML)
ISML Templates
ISML expressions are embedded inside ${…} to allow the ISML
processor to interpret the expression prior to executing an ISML tag or
the rest of the page. ISML expressions provide access to data by using
Dot notation. Here is an example of accessing a property of the
Product object in the pipeline dictionary:
${pdict.Product.UUID}
The difference between this ISML expression and one used inside a
pipeline node property (i.e. decision node) is that in ISML you must
specify the ${pdict.<object>.<property>} if you want to access a value
in the pipeline dictionary, whereas inside pipeline node properties the
access to the pdict is implicit and the ${} not used: i.e. Product.UUID
ISML expressions can also access Demandware Script classes and
methods. Some packages are available implicitly, so classes do not
need to be fully qualified:
dw.system.Site.getCurrent()
ISML expressions can also allow complex arithmetical, boolean and
string operations:
${pdict.Product.getLongDescription() != null}
With some HTML experience, most ISML tags and expressions don’t
require much example for you to understand how to use them. For
this module, we will cover the most frequently used tags: <isset>,
<isinclude>, <isdecorate>, <isloop> and the conditional tags <isif>,
<iselseif>, and <iselse>
We will cover more tags in subsequent modules.
IMPORTANT NOTE
Although there are some ISML tags that do not need a corresponding
closing </> tag (i.e.: the <isslot> tag), it is best practice to always use a
closing tag.
Page 99
Instructor Guide Internet Store Markup Language (ISML)
<isset
name = "<name>"
value = "<expression>"
scope = "session"|"request"|"page"
>
The value attribute can be either a hardcoded string or number or an
ISML expression accessing another variable or object:
expression value=”${pdict.Product.name}”
Page 100
Instructor Guide Internet Store Markup Language (ISML)
page: available only for a specific page, and its locally included
pages.
Page 101
Instructor Guide Internet Store Markup Language (ISML)
Page 102
Instructor Guide Internet Store Markup Language (ISML)
<isinclude>
<isdecorate>
<ismodule>
<iscomponent>
Saves time
<isinclude template=”[directory/]templatename”/>
You do not need to add the ‘.isml’ extension when including a template.
Page 103
Instructor Guide Internet Store Markup Language (ISML)
<isinclude template=”extras/calendar”/>
Template 2 (calendar.isml)
<h1>Included template</h1>
When the template gets rendered by the browser, the user will see:
My Template
Included template
IMPORTANT NOTE
• Local Include -All variables from the including template are
available in the included template, including page variables.
• Remote Include -Pipeline dictionary and page variables from
invoking template are NOT available on the included template.
The only variables available to a remotely included pipeline are
session variables.
• Includes from another server are not supported.
Page 104
Instructor Guide Internet Store Markup Language (ISML)
Page 105
Instructor Guide Internet Store Markup Language (ISML)
Remote Includes
The syntax for a remote include is
<isinclude url=”pipeline_url”/>
Page 106
Instructor Guide Internet Store Markup Language (ISML)
<isinclude url="${URLUtils.url(https://www.scribd.com/'BrowseCatalog-%3Cbr/%20%3E%20%20%20%20%20%20%20%20%20%20Hotdeals','catalogCategoryID','Storefront')}"/>
The page generated by the invoked pipeline can be dynamic or it may
come from cache. Caching will be covered later.
This tag allows you to pass as many attributes as you want without
having to use the URLUtils methods:
<iscomponent pipeline ="Product-Show" productid="1234"
name="Wide-screen television"/>
Page 107
Instructor Guide Internet Store Markup Language (ISML)
5. Add a remote include at the bottom of the template to show the last
visited products. Verify your syntax to make sure it is exactly as it
appears below:
<isinclude url="${URLUtils.url(https://www.scribd.com/'Product-IncludeLastVisited')}"/>
6. Test the pipeline with an existing product: ShowProduct-
Start?product= P0048.
7. On a different browser window, visit at least 3 other products in the
storefront.
8. Retest the pipeline: all the visited products should appear.
Page 108
Instructor Guide Internet Store Markup Language (ISML)
Page 109
Instructor Guide Internet Store Markup Language (ISML)
Decorator Exercise
1. In UX Studio, using the Search function, locate the
product/pt_productdetails.isml template.
Page 110
Instructor Guide Internet Store Markup Language (ISML)
1. The isml file which sets the values of any attributes of the custom
tag. See the example below in util/modules.isml:
<ismodule template="components/breadcrumbs "
name="breadcrumbs"
attribute="bctext1"
attribute="bcurl1"
attribute="bctext2"
attribute="bcurl2"
attribute="bctext3"
attribute="bcurl3"
/>
2. The isml file which specifies what happens when the attributes are
passed. See the code snippet from inside breadcrumbs.isml:
<isif condition="${pdict.bcurl1 != null}">
…
<a href="${pdict.bcurl1}" title="${pdict.bctext1}">
${pdict.bctext1}</a>
</isif>
3. Lastly, you need to invoke the custom tag inside an isml template:
<html …>
<isinclude template=”util/modules”>
<head>
…
</head>
<body>
…
<isbreadcrumbs bctext1=”…” bcurl1=”…” />
</body>
</html>
Page 111
Instructor Guide Internet Store Markup Language (ISML)
<isproducttile product="${pdict.Product}"/>
9. Test the pipeline with an existing product: ShowProduct-
Start?product= P0048.
10. In the custom tag invocation, enable other attributes expected by the
Page 112
Instructor Guide Internet Store Markup Language (ISML)
Page 113
Instructor Guide Internet Store Markup Language (ISML)
<isloop
iterator|items = "<expression>"
[ alias|var = "<var name>" ]
[ status = "<var name>" ]
[ begin = "<expression>" ]
[ end = "<expression>" ]
[ step = "<expression>" ]>
…do something in the loop using <var_name>…
</isloop>
Attribute Description
var (alias) Name of the variable referencing the object in the iterative collection
referenced in the current iteration.
status Name of the variable name referencing loop status object. The loop
status is used to query information such as the counter or whether it is
the first item.
Page 114
Instructor Guide Internet Store Markup Language (ISML)
begin Expression specifying a begin index for the loop. If the begin is greater
than 0, the <isloop> skips the first x items and starts looping at the
begin index. If begin is smaller than 0, the <isloop> is skipped.
step Expression specifying the step used to increase the index. If step is
smaller than 1, 1 is used as the step value.
Attribute Description
index The current index into the set of items, while iterating.
first True, if this is the first item while iterating (count == 1).
Loops Exercise
1. Open the Basket pipeline and the basket template.
2. Implement the following code to display the products in the cart:
Page 115
Instructor Guide Internet Store Markup Language (ISML)
5. Add a status attribute in the <isloop> tag so that you can see what
the count and index parameters return.
6. Replace the allProductLineItems property of the basket with the
method getProductLineItems().
Page 116
Instructor Guide Content Slots
Content Slots
Goal
The purpose is to utilize content slots to improve the appearance of
your site and to better showcase products and promotions.
Time
2 Hrs
Overview
We will demonstrate how to create content slots, their
corresponding rendering templates, and the use of content link
functions within content slots and HTML attributes in general.
Materials Needed
contentslot cartridge
Page 117
Instructor Guide Content Slots
Content Slots
Introduction
A content slot is an area on the page where a merchant defines
content to display based on certain qualifiers or rules.
Slots can easily be found on a page by using the Storefront Toolkit
> Content Information tool, as shown below. Hover the mouse
around the page to reveal where content slots are used, and to get a
link to the slot’s configuration page in Business Manager:
Page 118
Instructor Guide Content Slots
Content Slots
Creating Content Slots
Creating a content slot requires a collaborative effort:
1. The developer inserts a <isslot> tag in a template in the location
where the slot will appear.
2. The developer creates a rendering template for the slot that
defines how the slot data is to be presented.
3. The merchant creates a configuration for the slot in Business
Manager.
Slots can be of two kinds:
There are many rules that drive the appearance of a slot: marketing
campaigns, ranks, AB tests, customer groups, etc. Campaigns and
AB testing are out of the scope of this course since these subjects
are covered in Managing the storefront.
Page 119
Instructor Guide Content Slots
Global slot:
Category slot:
<isslot id=”category_top_featured” context=”category”
description=”…” context-
object=”${pdict.ProductSearchResult.category}” />
Whenever the template is saved, the new content slot will
automatically appear in the list of slots under Site > Online
Marketing > Content Slots. The platform achieves this by
automatically scanning any template for the use of the <isslot> tag.
Creating the Slot Rendering Template
As stated in the previous section, the slot will display one type of
content out of four possible types. The developer creates a
rendering template that takes into account the type of content, how
many objects to display, plus any CSS styling required for the slot.
The header_banner slot uses the htmlslotcontainer template
below as the rendering template:
<iscache type="relative" hour="24"/>
<div class="htmlslotcontainer">
<isloop items="${slotcontent.content}"
var="markupText">
<isprint value="${markupText.markup}"
encoding="off"/>
</isloop>
</isif>
</div>
Page 120
Instructor Guide Content Slots
<isprint value="${markupText.markup}"
encoding="off"/>
</isloop>
Page 121
Instructor Guide Content Slots
Page 122
Instructor Guide Content Slots
Here the merchant enters an ID, enables the slot and provides
other relevant information. The slot content that follows is the
most important piece for the programmer since it defines what
data becomes available for the rendering template.
For example, if the slot is to show HTML, the merchant might
configure the slot content as follows:
The merchant gave the banner an ID and enabled the slot. The
content type HTML was selected, which opens the HTML text area
(you can use the HTML Editor if you want to compose the HTML
from scratch). Then the ellipsis on the Template area was clicked:
this opens the Templates dialog shown above, and all the possible
rendering templates for this type discovered in all cartridges in the
cartridge path.
Page 123
Instructor Guide Content Slots
Page 124
Instructor Guide Content Slots
Here the merchant selects the Product content type, selects some
product IDs, and then has to choose from all the available product-
specific rendering templates. Notice that any slots/product
templates available in any cartridge in the path become visible.
Finally, the merchant needs to provide a schedule for the slot. This
is either the default schedule or based on a marketing campaign:
Page 125
Instructor Guide Content Slots
b. Enable it.
c. Make it the default.
d. Select HTML for the content type.
e. Using the HTML editor:
Page 126
Instructor Guide Content Slots
Page 127
Instructor Guide Content Slots
Page 128
Instructor Guide Content Slots
6. Navigate to
contentslot/static/default/css/verticalcarouselx4.css file.
Page 129
Instructor Guide Demandware Script (DS)
Goal
The purpose and goal of this module is to familiarize you with
using Demandware Script in ISML templates and script files.
Time
2 Hrs
Overview
We will discuss the Demandware Script syntax, API, as well as
how to create a new script pipelet.
Materials Needed
Solutions
Page 130
Instructor Guide Demandware Script (DS)
Overview
Introduction
The server-side language used for coding in the Demandware Platform is
Demandware Script (DWScript). Demandware Script is based on
JavaScript, which is standardized as ECMAScript. Demandware Script
implements the standards ECMA-262 (=ECMAScript 3rd Edition) and
the ECMA-357 standard, also known as ECMA for XML or E4X.
In addition Demandware supports all JavaScript language extensions by
Mozilla known as JavaScript 1.7. Demandware also supports optional
type specification (from JavaScript 2.0/ECMA 4th edition proposal and
ActionScript).
You use Demandware Script anywhere you need to access data
about the system, such as products, catalogs, prices, etc.
You write DWScript in pipelines inside Decision nodes, and in
ISML templates for expressions or inside <isscript> tags. But by
far the most extensive use of Demandware Script is inside Script
pipelets.
ISML
Decision
Node
Page 131
Instructor Guide Demandware Script (DS)
Overview, continued
Demandware Script API
There is a well-documented API that gets published with every
new Demandware update. The Script and pipelet APIs are
available under the Studio Help menus. The ISML documentation
(and more) is available in our documentation portal:
https://documentation.demandware.com/. The landing page
always redirects to the latest deployed version.
Demandware continually updates clients to the latest version by
using a mechanism called global deployment. Deployments
happen on Tuesday and Thursday between 2 and 7 am local POD
time. The current version number appears at the bottom of the
Business Manager screen and it corresponds to Year.Deployment:
Page 132
Instructor Guide Demandware Script (DS)
API Packages
Introduction
The Demandware Script API is organized in packages just like
Java.
However, you cannot inherit from these classes or packages when
you create a script, which is indeed different from Java. You can
only use properties and methods of these classes in your scripts.
TopLevel package
This is the default package in Demandware Script, similar to
java.lang in Java. It does not need to be imported in scripts. It
provides standard ECMAScript classes and extensions, such as:
Error, Date, Function, String, Math, Number, XML.
Page 133
Instructor Guide Demandware Script (DS)
IMPORTANT NOTE
In the following packages you will find many classes that end with
the word Mgr, for example: dw.catalog.ProductMgr. The role of
these classes is to retrieve instances of business objects related to
the package they belong to: you use ProductMgr.getProduct(String
id) to get a product using a unique identifier. The method returns a
Product instance which you can use to find information about the
product.
This pattern is repeated for all Managers.
eCommerce Packages
Page 134
Instructor Guide Demandware Script (DS)
Page 135
Instructor Guide Demandware Script (DS)
Inside of the <isscript> tag you can fully qualify every class you
want to use or you can choose to import any packages at the top of
the script:
<isscript>
importPackage(dw.catalog);
var siteCatalog = CatalogMgr.getSiteCatalog();
…
</isscript>
Page 136
Instructor Guide Demandware Script (DS)
Script Pipelets
Introduction
So far we have used Demandware pipelets to implement common
functionality in a Demandware storefront: the GetProduct pipelet. In
this lesson you will learn how to create your own script pipelets by
writing custom Demandware Script files.
Demandware Script files have an extension of .ds and are stored in
the /cartridge/scripts directory.
Script files like Pipelets, can have input and output parameters for
data manipulation. The example below shows input/output
parameters from a ‘GetProduct’ script:
When you create a new script file, the file will be preconfigured for
scripting. The example below shows a brand new script file:
Page 137
Instructor Guide Demandware Script (DS)
Script Pipelets
Input & Output Parameters
As noted previously, input and output parameters are configured
within the script text. The script text below is an example of an input
parameter that is called ‘ProductID’ which takes in a string value
while the output parameter is called ‘Product’ and returns a product
object:
When you first create a script file, the input and output parameters
are commented out with a *- so you will need to delete the minus
sign for the Demandware application to read the parameters:
For input/output data types, you can use TopLevel package classes
such as String, Number, Object, etc. You can also specify any other
data type as long as you fully qualify it: dw.catalog.Product. In the
following snippet the TopLevel.Object data type allows you to avoid
having to qualify the object you are returning:
@output Subscription : Object
@output Product : dw.catalog.Product Must fully qualify this output
type
Importing
When working with script files, if you access Demandware Script
packages or classes other than TopLevel, you will need to import
them in the script using the following syntax:
importPackage( dw.system );
You can import a single class, if you wish:
importClass( dw.system.Logger );
You can import a custom script from the same cartridge as the current
script you are writing:
importScript( "common/libJson.ds" );
Page 138
Instructor Guide Demandware Script (DS)
Script Pipelets
specify the cartridge prior to the script name:
importScript( "<cartridge name>:[folder/]utilities.ds" );
Of course, you can always fully qualify the access to a specific class
and avoid importing that package/class.
Using the Script Editor
You can turn on line numbers on the script by right-clicking the gray
column on the left side of the editor and selecting the Show Line
Numbers checkbox:
Warnings will appear for unknown methods after you save the file:
Page 139
Instructor Guide Demandware Script (DS)
Script Pipelets
The Script Editor allows you hover over the warning or error icon to
get more precise information about the offending usage:
Of course, this means that you will need to add the solutions
cartridge to the cartridge path so the script is found. In which order
the solutions cartridge appears in the path is not relevant from the
point of view of script access. However, the order of cartridges is
relevant for executing pipelines and templates, in which case the first
matching file found is used.
The ScriptLog Output
Every script pipelet used in a pipeline comes with a default
Dictionary Output property called the ScriptLog, of type String:
Page 140
Instructor Guide Demandware Script (DS)
Script Pipelets
You can write to the ScriptLog output within your script by using the
TopLevel.global.trace(msg : String , params : Object ...) method
which uses Java MessageFormat. While this capability exists in the
platform as a way to write debug or error messages to the pipeline, its
use is not recommended at this time. We suggest you use the
dw.system.Logger API to write to log files instead. This API is
covered later.
Page 141
Instructor Guide Demandware Script (DS)
Script Pipelets
3. In the Script File window, select the cartridge you want to store
your new script file.
4. Type <scriptname.ds> or <directory/scriptname.ds> in the Script
Name field:
5. Click OK.
6. To begin editing the script file, double-click on the new script
node. The script file will open up in the workspace using a
default script code template:
Page 142
Instructor Guide Demandware Script (DS)
Script Pipelets
2. Drag a Script Node from the palette onto the same location as the
removed pipelet, and complete the dialog as follows:
a. Select your cartridge to store the script.
Page 143
Instructor Guide Demandware Script (DS)
Script Pipelets
5. Modify the generated script code as follows or copy the code from
the GetProduct.ds file in the solutions cartridge:
Page 144
Instructor Guide Demandware Script (DS)
Script Debugging
Introduction
Studio gives you the ability to debug scripts as well as pipelines. In
order to use a script debugger you must first create a script debug
configuration. The process for creating a script debug configuration
is identical to the pipeline debug configuration setup:
Page 145
Instructor Guide Demandware Script (DS)
Script Debugging
Page 146
Instructor Guide Demandware Script (DS)
Script Debugging
d. Execute through the end of the pipeline (F8): the product name
should appear on the browser.
e. Fix any errors that you may have found, or just continue.
10. Debug the script again, but this time use an invalid product ID in
the URL:
a. Debug the script again, but this time use an invalid product id
in the URL:
b. Change the product URL parameter on the browser to a non-
existing product.
Page 147
Instructor Guide Demandware Script (DS)
IMPORTANT NOTE
Property files are suffixed by “ _<<locale>>.properties ” where
“<<locale>> ” stands for a specific locale term. For example,
“de” or “en” (or locale plus country like “de_DE” or “en_GB”).
The resource bundles contain key=value pairs where the key might
be compound (key.subkey) and the value is a hard-coded string
that uses Java MessageFormat syntax to implement parameter
replacement. Bundles stored in each cartridge within the
/templates/resources directory.
Page 148
Instructor Guide Demandware Script (DS)
Page 149
Instructor Guide Demandware Script (DS)
Page 150
Instructor Guide Forms Framework
Forms Framework
Goal
The purpose of this module is to describe the concepts and usage
of the Demandware Forms framework as well as demonstrate how
to implement a form in a pipeline.
Time
2.5 Hrs
Overview
We will study the following components of the forms framework:
xml metadata file, isml templates that display a form, specific
pipeline elements required for forms, and we will also demonstrate
how to create a new form.
Materials Needed
N/A
Page 151
Instructor Guide Forms Framework
Overview
Introduction
The Demandware platform provides a set of tools that help simplify
form display and processing. Using the Demandware Forms
framework, you can control how consumer-entered values are
validated by the application, rendered on a browser and possibly
stored on a server.
To utilize the Demandware form framework, you need at minimum
the following four files:
1. An xml form to define and store the metadata
Page 152
Instructor Guide Forms Framework
Overview
Example:
Given this form metadata XML file:
Page 153
Instructor Guide Forms Framework
Element Description
Attributes Description
formid Required: unique ID to identify the
field for ISML templates and pipelines
type Required: data type for field (see table
below)
label Usually a key to externalized string in
forms.properties resource bundle
description Description for field, might be used in
tooltips
min-length, max-length Restricts field length for data entry
min, max Valid range for integer, number and
Page 154
Instructor Guide Forms Framework
Overview
dates
range-error Message shown if value provided does
not fall within specified range
regexp Regular expression for string fields:
email, phone, zipcode, etc
parse-error Message shown when entered data
does not match regex. Usually a key to
an externalized string
mandatory Field required via server side
validation when true
missing-error Message shown when no data entered
for mandatory field
value-error Message shown if validation error
generated in pipeline
binding Used to match field to a persistent
object attribute
masked Specify # of characters to mask
format Format for display of dates, numbers,
etc
whitespace Specify whitespace handling (none or
remove)
timezoned Optional flag for date objects (true or
false)
default-value Pre-defines a value for a field
checked-value Value when field is checked in a form
unchecked-value Value when field is unchecked in form
Page 155
Instructor Guide Forms Framework
Overview
Here is an example of a simple form metadata file:
<?xml version="1.0"?>
<form xmlns="http://www.demandware.com/xml/form/2008-04-19">
In the example above, the fields fname, lname and email store the
information needed to send a newsletter to a non-registered user.
The fields are:
Mandatory
IMPORTANT NOTE
Although it is not a requirement, it is a best practice to use lower-
case letters when naming your xml forms. Pipelines are also xml
files and use camel-case naming in SiteGenesis.
Page 156
Instructor Guide Forms Framework
The custom tag will use the fname formid from the metadata file
and build an HTML label using the forms.properties file to pull
the text for the forms.contactus.firstname.label key. It also creates
an HTML input field to the right of the label with the necessary
client-side JavaScript to enforce required fields, as shown below:
Page 157
Instructor Guide Forms Framework
Overview
The final requirement in the ISML template is to implement the
button that matches the action in the form metadata. For this we
create a standard HTML button with a name attribute that points
to a specific action in the form metadata:
<input type="submit"
value="${Resource.msg('global.submit','locale',null)}"
name="${pdict.CurrentForms.newsletter.subscribe.htmlName}"/>
Page 158
Instructor Guide Forms Framework
Page 159
Instructor Guide Forms Framework
Page 160
Instructor Guide Forms Framework
a. Study the fields and action in the newsletter.xml file from the
solutions cartridge.
b. Save newsletter.xml into your cartridge.
c. Study forms.properties in the storefront cartridge: this resource
file contains the localized strings used in the form metadata file.
2. Define a template to capture form data:
a. Study the use of the <isinputfield> custom tag in the
newslettersignup.isml template in the solutions cartridge.
b. Study the use of the URLUtils.httpsContinue() method. What
will this method accomplish in the context of the form action?
c. Save newslettersignup.isml from the solutions cartridge into
your cartridge.
3. Create a template to display the form values submitted:
a. Save newslettersuccess.isml from the solutions cartridge into
your cartridge: this displays a “Thank you <fname> <lname>
for signing up”.
b. Save locale.properties from the solutions cartridge into your
cartridge: this file contains the externalized strings used in
newslettersignup.isml and newslettersuccess.isml
Page 161
Instructor Guide Forms Framework
Template: newslettersignup.isml.
Page 162
Instructor Guide Forms Framework
Page 163
Instructor Guide Custom Objects
Custom Objects
Goal
The goal of this module is to use custom objects and transactional
pipelets to store data that does not naturally belong in any other
Demandware system object. An additional goal is the use of
defensive coding and custom logging to improve the quality of the
code.
Time
2 Hrs
Overview
We will define custom objects and create instances
programmatically. We will use a transactional pipelet to save the
custom object in the database, and implement custom logging to
allow debugging and error messages to be written to logs.
Materials Needed
The following cartridges are needed to run this module: storefront
and solutions
Page 164
Instructor Guide Custom Objects
IMPORTANT NOTE
You should always consider first if a Demandware System
object (Product, Catalog, etc) can be used instead of creating a
custom object. Please do not abuse the fact that you can create
custom objects: they are best used to store static data (like
configuration parameters), not for uncontrolled amounts of
data (like analytics). Custom objects searches can be slow if the
data is large. You should consider data growth and cleanup in
your COs. Demandware Platform Governance has quotas
around custom object API usage and data size which will be
enforced in the future.
Page 165
Instructor Guide Custom Objects
Page 166
Instructor Guide Custom Objects
Page 167
Instructor Guide Custom Objects
12. Enter a name for your grouping in the ID field and a name
in the Name: field.
13. Click the Add button. You will need to add the field
attributes next.
14. Click the Edit link to add field attributes to the group.
15. Click the elipse next to the ID: field to select field attributes.
16. Select the attributes you wish to add from the list by clicking
in the checkbox next to each one. Then click the ‘Select’
button.
Page 168
Instructor Guide Custom Objects
17. You are now ready to view, add, and edit new instances of
the custom object type you just created in the Custom
Object Editor section. We will next give you the steps for
creating new custom objects manually.
Page 169
Instructor Guide Custom Objects
4. At the next window, select the custom object type you wish to
manage from the drop-down list.
6. Enter data in each of the required fields and then click the
Apply button.
7. You have now created a custom object. Click the Back button
to exit the custom object editor.
Page 170
Instructor Guide Custom Objects
a. ID – NewsletterSubscription
b. Key Attribute – email, type String
c. Data Replication – not replicable
d. Storage Scope – Site
Page 171
Instructor Guide Custom Objects
This inheritance tree means that COs are persisted in the database and
can have custom attributes added by an administrator or programmer
in Business Manager. As you inspect the Demandware documentation
you will see that commonly used classes like dw.catalog.Product,
dw.system.SitePreferences and many others share this inheritance tree:
objects of these class types are saved in the database and can be
extended to store extra attributes.
This will create an instance with a system generated, unique PK. You
could also use:
CustomObjectMgr.createCustomObject("NewsletterSubscription", args.email));
This assumes that the args.email value should be a unique string every
time a CO is created. Otherwise, a duplicate PK error will occur.
Page 172
Instructor Guide Custom Objects
Page 173
Instructor Guide Custom Objects
co.custom.firstName = args.firstName;
co.custom.lastName = args.lastName;
args.subscription = co;
return PIPELET_NEXT;
}
Notice the use of the custom qualifier for all the custom attributes that
you defined in the CO definition: without this qualifier the code will fail
since the class dw.object.CustomObject does not have any standard
attribute named firstName.
Page 174
Instructor Guide Custom Objects
5. For the case the same email subscription already exists connect the
error exit of the script node to an interaction node holding a template
stating :
<h4>An error occurred in your subscription (Duplicate email ?).</h4>
Back to <a href="${URLUtils.url(https://www.scribd.com/'Newsletter-Start')}">Newsletter
Subscription</a>.
Page 175
Instructor Guide Custom Objects
Custom Logging
Introduction
The Demandware platform supports custom logging using log
categories and severity levels as defined by the Apache log4j open
source project.
Log4j supports multiple severities and categories of logging to allow
the developer to capture debug message at different levels of
granularity without having to turn everything on. The severity levels
are:
Debug < Info < Warn < Error < Fatal
product
product.import
product.import.staging
Page 176
Instructor Guide Custom Objects
Warn, Error and Fatal messages are logged for "product" and all
its sub-categories.
Debug and Info are logged for "product.import" and all its sub-
categories.
To write to a custom log, you will need to use the
dw.system.Logger.getLogger() factory method. This method creates
a Logger object for a specified category:
var logger : Logger = Logger.getLogger( “category" );
// Write to debug log
logger.debug("Input params received in pipelet
firstName: {0}\n lastName: {1}\n email: {2}",
args.firstName, args.lastName, args.email);
try
{
… do something…
return PIPELET_NEXT;
}
catch (e)
{
// Write to warn log
logger.warn(“error description: {0}", e.causeMessage );
return PIPELET_ERROR;
}
You can use the Logger object to write a message for a specific
severity level: Logger.error(String msg).
The message uses the Java MessageFormat API, so you can specify
placeholders. Typically these messages are not localized since they
are read internally by site administrators, but they can be.
Enabling Custom Logging
In order to write to log files you will need to enable Custom Log
Settings under Administration Operations in Business Manager:
Page 177
Instructor Guide Custom Objects
4. Enable the checkbox next to the log category you wish to write to.
5. Click the Apply button.
Page 178
Instructor Guide Custom Objects
Page 179
Instructor Guide Custom Objects
Review
Custom Object Questions True False
Page 180
Instructor Guide DataBinding and Explicit Transactions
Goal
The goal of this module is to use data binding to update persistent
objects with form data and vice versa. Since this task often
requires multiple steps, we will also cover the use of explicit
transactions to accomplish a multi-step process.
Time
2 Hrs
Overview
We will discuss how to use UpdateFormWithObject and
UpdateObjectWithForm pipelets to pre-populate forms and update
the database after the form is submitted. Also, we will use an
explicit transaction to commit changes to the database on a
modified version of the Newsletter exercise.
Materials Needed
The following cartridges are needed to run this module: solutions,
customerpreferences
Page 181
Instructor Guide DataBinding and Explicit Transactions
Page 182
Instructor Guide DataBinding and Explicit Transactions
Page 183
Instructor Guide DataBinding and Explicit Transactions
Notice that a form group may be updated with an object: as long as the
bindings match, just that part of the form will be updated.
In the example above, the profile.xml form has a customer group that
will be updated with the existing profile data from the logged in
customer:
Page 184
Instructor Guide DataBinding and Explicit Transactions
Page 185
Instructor Guide DataBinding and Explicit Transactions
Page 186
Instructor Guide DataBinding and Explicit Transactions
Page 187
Instructor Guide DataBinding and Explicit Transactions
Page 188
Instructor Guide DataBinding and Explicit Transactions
Page 189
Instructor Guide DataBinding and Explicit Transactions
Form: CurrentForms.preferences
Object: CurrentCustomer.profile
Optionally you can switch the Configuration->Clear setting
to true instead of adding the previous ClearFormElement
pipelet.
f. Copy the editpreferences.isml from the customerpreferences
cartridge to your own. Make sure the formfields are matching
the formids of the preferences.xml metadata file.
g. Add an ICN. Make it point to editpreferences.isml. Start name
“Preference”.
h. Add an UpdateObjectWithForm pipelet after the apply
transition with the following properties:
Form: CurrentForms.preferences
Object: CurrentCustomer.profile
i. Add an Assign pipelet that maps the first expression
dw.web.URLUtils.https('Account-Show') to the first variable
called Location. This will redirect you to the Account-Show
pipeline after pressing the apply button.
j. End the pipeline with an interaction node that invokes the
util/redirect template (in the storefront cartridge).
k. Verify that the pipeline looks as follows:
Page 190
Instructor Guide DataBinding and Explicit Transactions
Page 191
Instructor Guide Data Integration
Data Integration
Goal
The purpose and goal of this module is to understand how external
data is integrated into the Demandware Platform.
Time
3 Hrs
Overview
We will discuss how batch feeds (asynchronous integrations) are
configured, and how Web Services are used for synchronous
integration.
Materials Needed
The following cartridges are needed to run this module:
delete_custom_object, int_simplefeeds, test_simplefeeds,
int_inventoryws and test_inventoryws
Page 192
Instructor Guide Data Integration
Web Services
All new Demandware clients need to integrate data from other
data systems. This lesson will cover the best practices for
determining what type of integration is most effective depending
on the frequency needs of the data.
Typical integration data points in Demandware are:
Page 193
Instructor Guide Data Integration
File Format
The file format for the incoming and outgoing feeds is the standard
Demandware import/export format. For XML files the schema
definitions (XSD files) can be downloaded from Customer Central. A
good approach to create a sample file is to set up the data as desired in
Business Manager, run an export from the Business Manager user
interface and use the exported file as template.
All import files can alternatively be provided in gzip format (not to be
confused with zip). In that case provide the file with extensions
.xml.gz or .csv.gz at the File Transfer Server and adjust the file
matching rule. The validation and import processes will automatically
unzip the files during processing.
Page 194
Instructor Guide Data Integration
You can define jobs that execute on the global (or organization) level
and jobs that execute only on a site level through
Administration > Operations.
Page 195
Instructor Guide Data Integration
Page 196
Instructor Guide Data Integration
Page 197
Instructor Guide Data Integration
Page 198
Instructor Guide Data Integration
Page 199
Instructor Guide Data Integration
Page 200
Instructor Guide Data Integration
IMPORTANT NOTE
It is not advisable to expose the RunJobNow pipelet in a public
pipeline as this could be exploited to flood your job queue. If
you must use this pipelet in the storefront, please implement a
custom security mechanism so that only authorized requests can
execute the pipelet.
Page 201
Instructor Guide Data Integration
Page 202
Instructor Guide Data Integration
e. Now click on Import button on the top (Meta Data, not the one
in the Geolocations section.
C:\projects\training\simplefeeds\documentation\Tasks
XMLCatalogOnly.xml file using your favorite editor.
Page 203
Instructor Guide Data Integration
https://mydisk.se/training/studentXX/
</remote-folder-url>
<error-email>[email protected]</error-email>
Page 204
Instructor Guide Data Integration
b. On the Sites tab select the SiteGenesis site and click on Apply
button
Page 205
Instructor Guide Data Integration
c. Test the job by running the feed job from Business Manager.
Page 206
Instructor Guide Data Integration
Page 207
Instructor Guide Data Integration
Page 208
Instructor Guide Data Integration
As mentioned previously, the WSDL file is all that is needed for the
Demandware server to generate the java classes for accessing the
methods in the remote service. You will need to write a script file
for accessing those classes using the Demandware API.
Page 209
Instructor Guide Data Integration
Page 210
Instructor Guide Data Integration
Page 211
Instructor Guide Data Integration
Question Answer
c) The WSDL
a) FTP
b) WEBDAV
c) SFTP
Page 212
Instructor Guide Deconstructing SiteGenesis
Deconstructing SiteGenesis
Goal
The purpose and goal of this module is to familiarize you with the
files used in SiteGenesis to render pages to a browser.
Time
4 Hrs
Overview
We will discuss the common files used to render pages in
SiteGenesis and give an overview of the shopping cart checkout
process.
Materials Needed
int_inventoryws, test_inventoryws, and inventorycheck cartridges.
Page 213
Instructor Guide Deconstructing SiteGenesis
Overview
Introduction
As we discussed in the Demandware Architecture module,
SiteGenesis is the reference storefront application for new client
development.
The main pipelines used for generating storefront pages are:
Search-Show
Product-Show
Page-Show
Cart-Show
Account-Show
The first 3 pipelines currently support SEO friendly URLs :
studentXX.training.dw.demandware.net
By now you should be able to open any pipeline in Studio and execute
it from the storefront, using the debugger to step through each
pipeline process.
SiteGenesis Page Deconstruction Tools
You can use the Storefront Toolkit Page Information tool to help you
break down the files used to generate a storefront page.
Page 214
Instructor Guide Deconstructing SiteGenesis
When you want to know what ISML templates are being used to
generate a page, use the ‘Page Information’ tool. When using the
‘Page Information’ tool, you can quickly open up a template that is
used to generate a page.
Page 215
Instructor Guide Deconstructing SiteGenesis
11. Click the template link (be sure UX Studio is open) to open the
template rendering the area of the page.
Page 216
Instructor Guide Deconstructing SiteGenesis
Storefront Files
Introduction
Some important files used in SiteGenesis for rendering pages to a
browser are:
You should open each file to see the functionality being managed by
each one.
Page 217
Instructor Guide Deconstructing SiteGenesis
Storefront Files
IMPORTANT NOTE
Certain ISML templates may include assets designed to support
advanced UI functionality. In these cases, those specific includes
should be removed and a single include to
<TEMPLATE_NAME>_UI.ISML is inserted. A blank
<TEMPLATE_NAME>_UI.ISML is created in Core as a blank file to
ensure Core does not break. Then the
<TEMPLATE_NAME>_UI.ISML file is created in Rich UI. In the Rich
UI version, all of the specific element includes will be inserted.
Page 218
Instructor Guide Deconstructing SiteGenesis
Storefront Files
Product Page Templates
There are many templates that are included in a product page:
Page 219
Instructor Guide Deconstructing SiteGenesis
Storefront Files
Product Sets
When a product is part of a product set, the page is rendered with
product.isml and includes the template producttopcontentPS.isml.
c. CurrentHttpParameterMap.source to determine if
quickview, viewed from cart, or ajax search
d. CurrentVariationModel to build the variation swatches
Page 220
Instructor Guide Deconstructing SiteGenesis
Storefront Files
Walk students through viewing PDP events in Firebug:
Cart
COCustomer
COShipping
COBilling
COPlaceOrder
COSummary
Page 221
Instructor Guide Deconstructing SiteGenesis
Both of these objects must contain all of our individual items that we
need to charge to the user. Because we may want to send different
items in the same order to different addresses, items are grouped into
shipments.
Shipment 1
• Item 1
• Item 2
Shipment 2
• Item 3
• Item 4
Shipment 3
• Item 5
• Item 6
All of these objects inherit from the class LineItemCtr (line item
container). Let’s have a look at what these objects can contain.
LineItem Class
The base class used to represent any type of item to be included in the
calculation of totals is the LineItem. There are many different types of
line items, but they all serve basically the same purpose. A line item can
be thought of exactly like a line item of an invoice which will later be
used to sum up all of our invoice (or Basket > Order) totals and
subtotals. So we create line items in our basket that represent a quantity
of an item on our invoice, be that a shipping cost, coupon to be
redeemed or a product to be purchased:
Amount
Item Description
Each Ct. tax Totals
Men’s Black Leather Shoe
00956TW $125.00 1 8.75 $133.75
Women’s Leather Coat 45342VT $75.95 1 5.31 $81.26
Gift Certificate -$50.00 1 x - $50.00
Shipping $7.50 1 $7.50
TOTAL $172.51
Page 222
Instructor Guide Deconstructing SiteGenesis
1. Get the most current Basket data associated with the session from
the database. This is done by calling the GetBasket pipelet. In
SiteGenesis a private pipeline for this is available:
Cart-GetExistingBasket sub-pipeline
Page 223
Instructor Guide Deconstructing SiteGenesis
3. Prepare the view. Retrieve any other data from the system that you
need for this page. Examples of this could be calculating applicable
shipping methods or payment methods. Other examples may be
retrieving basket or user specific product recommendation or
promotional data. This step needs not be performed in a pipeline, it
may also be performed in the isml template, or using ajax calls which
is often preferred so that this data can be refreshed in real time as the
user makes changes to relevant data on the page.
You now should be prepared to render your checkout page using an
ICN (interaction continue node.) It is not required to use an ICN node
in checkout but they come with many advantages, such as automatic
form validation and the concept of form actions which allows you to
create very diverse page flow without having a lot of public entry
points for pages.
Now let’s walk through SiteGenesis and see some of these concepts in
action.
Page 224
Instructor Guide Deconstructing SiteGenesis
And a full-page cart display that opens when the View Cart button is
pressed from the mini-cart or the cart link is clicked:
Page 225
Instructor Guide Deconstructing SiteGenesis
When a customer puts a product into the basket, the process is typically
done with an ajax call. The ajax call invokes the Cart sub-pipeline that is
located in the Cart pipeline.
AddItem Sub-Pipeline
The AddItem sub-pipeline adds a product to the mini cart. The pipelet
AddProductToBasket creates a ProductLineItem (representing the
added product sku and quantity) in the basket and also returns this
object in the pipeline dictionary.
Page 226
Instructor Guide Deconstructing SiteGenesis
Page 227
Instructor Guide Deconstructing SiteGenesis
Below you can now see the skeleton of the cart form object under the
CurrentForms key. Later we will fill this form with the current data
from our basket object.
Page 228
Instructor Guide Deconstructing SiteGenesis
After we guarantee our form objects all exist, we get the current existing
basket from the database. Once we have ensured the basket object is
available in the dictionary, the pipeline Cart-PrepareView first updates
the form objects with the basket data, then it retrieves any page specific
data we still require. In this case, if the user is a registered user and
authenticated, we fetch any wish lists that are associated with the user
or create one if none is found. Finally, the page is rendered using an
ICN with many continue actions. Let’s have a look at where these
actions are called on the cart page.
There are many form actions that can be taken from the cart ICN. All of
these actions either continue the checkout flow, or perform a business
operation and return the user to the cart page. Here are some brief
explanations of what these actions do:
Page 229
Instructor Guide Deconstructing SiteGenesis
Cart-COStart Sub-Pipeline
The COStart sub-pipeline within the Cart pipeline starts the checkout
process. It validates that the basket total could be calculated (not N/A,)
that the products represented by the line items are still available on the
site and that any coupons added to the basket are valid. If successful,
the pipeline jumps to the COCustomer pipeline’s Start node.
Page 230
Instructor Guide Deconstructing SiteGenesis
COCustomer Pipeline
The first step of the checkout process is to provide an option to the
visitor to choose checkout type (returning, guest or create account).
For the purposes of this lesson, we will assume the visitor selects to
proceed with an ‘unregistered user’ checkout process.
Page 231
Instructor Guide Deconstructing SiteGenesis
COShipping Pipeline
The COShipping-Start pipeline Start node is the starting point for single
shipping scenario.
After performing the steps outlined above, this pipeline displays an ICN
that asks for visitor input of where they want their items to be delivered.
Page 232
Instructor Guide Deconstructing SiteGenesis
Page 233
Instructor Guide Deconstructing SiteGenesis
If the visitor had selected in the shipping form to use the same address
for billing, then the address will be pre-populated from those fields.
Page 234
Instructor Guide Deconstructing SiteGenesis
As part of step 3 (prepare the view) for the billing page, we will retrieve
a list of applicable payment methods and cards.
Page 235
Instructor Guide Deconstructing SiteGenesis
After these final checks are complete, inventory for the order is reserved
using the ReserveInventoryForOrder pipelet and a database transaction
is opened. Next is the process of creating an order number and
processing the payment.
The processing of the payment method ends with either:
Authorize
End
Decline
Error
Page 236
Instructor Guide Deconstructing SiteGenesis
Once the order is placed and the database transaction has successfully
been commited, a confirmation email is sent to the buyer. The pipeline
will then exit with a jump node to COSummary-ShowConfirmation
which displays a confirmation ICN node to the buyer that gives the
buyer the option of creating an account. If order creation has failed, the
pipeline exits with a jump node back to the order summary page.
Page 237
Instructor Guide Deconstructing SiteGenesis
Page 238
Instructor Guide Deconstructing SiteGenesis
Note: the inventorycheck cartridge contains the solution for this lab.
1. If not already installed, install the pre-built integration cartridge
int_inventoryws and test_inventoryws in your cartridge path.
2. Create a new private pipeline to perform the additional logic
Drag your end node down several nodes and add a join node
directly before it. Drag the ERROR connector from your
script pipelet to this join node.
e. Add a call node to the InventoryWS-GetInventoryLevels
pipeline which is inside the int_inventoryws cartridge. Create
two transitions, one labeled next which continues with the flow,
and another called ERROR which transitions back to the join
node created in d.iii.
Page 239
Instructor Guide Deconstructing SiteGenesis
record.setAllocation(ats);
Page 240
Instructor Guide Deconstructing SiteGenesis
Page 241
Instructor Guide Deconstructing SiteGenesis
Page 242
Instructor Guide Site Maintenance
Site Maintenance
Goal
The purpose and goal of this module is to familiarize you with the
tools available to you for improving site performance and
replicating code and data.
Time
2 Hrs
Overview
We will demonstrate how to use the Pipeline Profiler, discuss how
to implement page caching, and discuss and demonstrate how to
replicate code and data in the P.I.G.
Materials Needed
None
Page 243
Instructor Guide Site Maintenance
status = "off|on"
Page 244
Instructor Guide Site Maintenance
hour = integer
Indicates caching duration or time of day. If the type attribute
is set to daily, the hour value must be an integer ranging from 0
to 23. If type is set to relative, all integer values greater than 0
are valid (the default value is 0, meaning either the page is
never cleared from the cache or only the minute attribute is
relevant).
minute = integer
Indicates caching duration or time of day. If the type attribute
is set to daily, the minute value must be an integer ranging
from 0 to 59. If type is set to relative, all integer values greater
than 0 are valid (the default value is 0, meaning either the page
is never cleared from the cache or only the hour attribute is
relevant).
varyby="price_promotion"
Lets you mark a page as personalized: this does not mean that
the page is unique for a person but rather that different versions
of the same page showing different prices, promotions, sorting
rules or AB test segments will be cached by the Demandware
platform. For example, this parameter is necessary for product
pages since a customer belonging to a customer group might
get special promotions that other customer groups don’t get.
While the ISML template is the same, the generated pages vary,
and therefore caching every version of the page benefits
performance. For performance reasons, a page should be only
marked with the varyby property if the page is really
personalized; otherwise, the performance can unnecessarily
degrade.
Page 245
Instructor Guide Site Maintenance
For example, the page below will be cached for 1 hour and 30
minutes:
Page 246
Instructor Guide Site Maintenance
3. Add a Date object to the page that prints the current time:
<isprint value="${new Date()}" style="DATE_TIME" />
Page 247
Instructor Guide Site Maintenance
The page will now show special icons that you can click to reveal
how the whole page and its remote includes are cached:
Page 248
Instructor Guide Site Maintenance
4. Study the cache information for a content slot and open the
template to see the cache settings.
5. Study the cache information for the Cart remote include: why
is this page not cached?
Page 249
Instructor Guide Site Maintenance
Site Performance
Introduction
The Pipeline Profiler is a tool in Business Manager that gives you
insight into pipeline and script performance.
This tool helps you track pipeline execution metrics, which is a critical
component of overall page and site load and performance. Using this
tool enables you to proactively identify bottlenecks in performance
while developing applications.
It is located in Administration > Operations > Pipeline Profiler.
Page 250
Instructor Guide Site Maintenance
Site Performance
Profiler Off
Profiler On
5. Browse specific pipeline in storefront
6. Return to profiler and analyze the collected data
a. Click the site link you are capturing data for:
c. Look for Pipelines with high average run times and high hits.
These will be the first areas to improve performance.
d. To view data for a pipeline at a more granular level, click on
the pipeline name.
Page 251
Instructor Guide Site Maintenance
Site Performance
Page 252
Instructor Guide Site Maintenance
Code Replication
Introduction
Code replication is set and managed in Business Manager. Once you
have uploaded a new code version to the P.I.G. staging instance, you
can set code replication to occur between staging and development or
staging and production.
Code Replication Overview
In a typical development environment, a source management system
is used for code version control. Each developer uses their own
sandbox for development, while checking in their code to a source
management system.
Page 253
Instructor Guide Site Maintenance
Code Replication
For major code changes, it is recommended to use a sandbox for
testing:
For testing in a sandbox, you will need to export site data to the
global directory from staging and import it into your sandbox using
the Site Import/Export module in Business Manager.
When code meta data (site preferences, new attributes, etc.) needs to
be tested, a replication from STAGING to DEVELOPMENT should be
performed by a build engineer:
This is also good practice for testing processes without impacting the
production storefront (i.e. Product import feed).
The last step in code replication is moving code from STAGING to
PRODUCTION.
Page 254
Instructor Guide Site Maintenance
Code Replication
Data replication will be covered in the next lesson.
6. Click Next.
7. At the next screen, specify what type of replication you want:
Page 255
Instructor Guide Site Maintenance
Code Replication
Page 256
Instructor Guide Site Maintenance
Data Replication
Introduction
Data replication is a process to promote merchant edits, product
and system objects from Staging to Production (or Development).
The best practice is to replicate to development first, verify that
data and storefront work and then replicate from staging to
production.
Data can be replicated granularly:
Organization objects
Page 257
Instructor Guide Site Maintenance
Data Replication
Page 258
Instructor Guide Site Maintenance
Data Replication
To replicate data from STAGING to DEVELOPMENT or
STAGING to PRODUCTION, follow these steps:
1. Log into the STAGING Business Manager with an account that
has code replication permissions.
2. Click AdministrationReplicationData Replication.
3. Click New to create a new data replication process.
4. Specify the target for the data replication process.
7. Click Next.
8. At the next screen, specify what type of replication you want:
5. Next, expand the sites to select the site data you wish to
replicate.
Page 259
Instructor Guide Site Maintenance
Data Replication
6. Click Next.
7. Click Start to create and trigger the process immediately. Click
Create to add the replication process to the list. Click Cancel to
go back to the list of replication processes without saving
anything.
8. If you clicked Create, to start the process, click Start from the
list of processes.
Page 260