当前位置:   article > 正文

Demandware Concept - Review For Did Exam

Demandware Concept - Review For Did Exam

SaaS platform: Software as a Service 

Software and applications are hosted on the internet and delivered to customers who pay for access.

 

POD: Point of Delivery 

Demandware hardware deployed in a data center

contains multiple state-of-the-art(尖端)application servers, database servers and the clustering(聚合) and BACKUP infrastructure (基础构架) to support multiple client Realms

 

Realm

Each Demandware Customer is allocated one or more Realms.

A Realm = collection of resources (used for developing, testing, hosting one or more Demandware eCommerce sites)

 

Instance

A single running Demandware server, hosted in the Demandware hardware infrastructure.

 

Primary Instance Group

Every Realm includes a Primary Instance Group (PIG)

    Every PIG includes 3 Demandware instances: 

 Production : production , live instance, actual eCommerce storefront

 Staging : uploading code, preparing for testing  in the Development instance

 Development : test processes without impacting (影响) the production storefront (ie. 商品导入)

 

Secondary Instance Group 

Every Realm includes a Secondary Instance Group (SIG) 

which includes 5-47 Demandware Sandboxes

 

Sandboxes: 

used by developers to develop and test their code.

not as powerful as PIG instances in performance, memory and storage.

 

Business Manager Overview

used by both merchants and developers for managing administrative (管理行政) tasks

 

Merchandisers use Business Manager

• Products & Catalogs 

• Content

• marketing campaigns 

• Search settings

• Customers

• Site Analytics

• Site URL’s

• Site Preferences

 

Developers use Business Manager

• Code & Data Replication 代码数据复制

• Code Versioning 代码版本控制

• Site Development 

• Data Import/Export

• Global Preferences for all sites /organization 全局参数配置

 

SiteGenesis Foundation Architecture(基础构架)

sample for developers:

pipelines, scripts, and ISML templates 

sample for merchants:

configurations for catalogs, categories, products

 

Get latest version SiteGenesis:

 the read-only SiteGenesis package needs to be imported as a sample site in every Sandbox instance(!!Sandbox)

 

警告事项:

Can't import SiteGenesis to PIG.

Can import SiteGenesis to SIG.

Import SiteGenesis(may not work) Before import CUSTOM sites(work ok).

 

Site Configuration 站点配置:

After import site, Disable the cache.

 

Index

for search for products from the storefront

 

Share data between sites

A site must have only one site catalog, but may have one or many master catalogs.

OnlineFlag attribute allow for one product to be online in one site, but offline on another site.

 

IDE: Integrated Development Environment

 

A workspace = an Eclipse-specific local directory ( contains Eclipse projects)

 

workspace 

1.Either define a connection to a Demandware instance

Or point to a Demandware cartridge

2.never compile Java projects  (not use java in dw)

3.one client <->one server connection<->one workspace

 

Creating server connection (1-way push only)

for: upload your code to a Demandware server

not be able to : pull the code onto your personal computer from the Demandware server

under: File –> New -> Demandware Server Connection

 

Demandware Help

Click : Help ->Help Contents. Expand the Demandware API link

 

Projects (Cartridges)

A project = a cartridge =  a folder with specific sub-folders and files inside of it

 

Demandware Views

 specific Demandware programming files: Cartridges, Pipelines, Pipelets, Templates, and Scripts. 

The Navigation tab : all files in a tree view 

 

Searching for Text in Files: Search -> Search

 

Cartridges: 

A cartridge = a directory structure 

flexible deployment mechanism for customized functionality

 

Contain many different  types of files:

static files: CSS, JavaScript,images, WSDL files

Demandware specific files:pipelines, scripts, templates, form definitions

 

storefront.properties (A Required File)

generated by Studio When create new cartridge

 

Cartridge Path

Demandware server will use the first one it finds

Administration -> Sites -> Manage Sites -> Select Site -> Settings tab

 

Format: 

a colon (:) between cartridge , case sensitive ,

no spaces between each item

e.g.   training:storefront_richUI:storefront

 

Cartridge Types:

i.Storefront cartridge

ii.Demandware cartridge

iii.Business Manager cartridge

 

At least one storefront cartridge

 

Storefront Cartridge :

A new storefront  cartridge = a copy of the default SiteGenesis cartridge

 

Demandware Cartridges functionality:

1.Generic: reusable code used in multiple sites 

2.An integration to an external system

3.Specific to a localized site: css , images and resource files for a language-specific site.

 

Best Practices:

1. keep a SiteGenesis cartridge for comparison,

    not make it a part of cartridge path

 

2. <client>_core: common code reuse in multiple sites

 

3.<app>_site: site-specific functionality, overwrite the core

 

4. int_<site>: integration code

 

View WebDAV cartridge directory in BM :

i.Administration -> Site Development -> Development Setup

ii.In the WebDAV Access section, click the link for Cartridges.

 

Create a new version on the server

i.Administration -> Site Development -> Code Deployment.

ii.Click Add to create version2. Click Apply.

iii.open the Demandware -> Change Upload Staging Directory…

 

Create a new empty cartridge

File -> New -> Demandware Cartridge

 

Creating a Storefront Cartridge

a copy of the 

sitegenesis_storefront_richUI , sitegenesis_storefront_core cartridges 

will be downloaded to your workspace and renamed with the name you specify

 

Core :  

business layer: 

“server” side components: Pipelines , Demandware Scripts

non-JavaScript version

simple presentation layer:

contain ISML templates, Common CSS files, Forms and Resource files.

no JS, AJAX

 

Rich UI:

specific CSS, advanced UI elements, 

no ISML, but an initialization mechanism in order to effect changes to the rendering of Core templates in the client browser

 

make changes to the new storefront cartridge viewd immediately show changes:

i.Set the cartridge to be uploaded to your workspace server

ii.Put the new cartridge in the cartridge path

iii.Have site caching disabled for the site

 

Pipelines

stored in XML files

both locally on your PC and on the server

stored within the context of a cartridge

searches for the pipeline in the cartridge's path and uses the first one it finds

 

Fifteen different pipeline elements:

 

1. Start Node

Begins the logical branch of a pipeline.

 

2. Interaction Node (交互节点)

Used when a request requires a page as a response.

 

3. Transition Node (过渡节点)

Defines a path along a pipeline between pipeline nodes.

 

4. Call Node

Invokes a specified sub-pipeline. After the sub-pipeline execution the workflow returns to the calling pipeline.

 

5. End Node

Used to terminate a sub-pipeline, returns to the calling pipeline.

 

6. Jump Node

Used when the pipeline forwards the request to another pipeline.

 

7. Join Node

Provides a convergence point for multiple branches in workflow.

 

8. Interaction Continue Node (交互继续节点)

Processes a template based on user action via a browser.

 

9. Script Node

Used to execute Demandware scripts.

 

10. Eval Node (运算节点)

Evaluates an expression.

 

11. Assign Node (赋值节点)

Used to assign values to new or existing Pipeline Dictionary entries, using up to 10 configured pairs of dictionary-input and dictionary-output values.

 

12. Stop Node

Used to terminate a sub-pipeline and calling pipelines, stops execution immediately. Used in pipelines that executes a batch job.

 

13. Loop Node

Used to loop through an iterator.

 

14.Pipelet Placeholder (Pipelet占位符)

Placeholder for a script node.

 

15. Decision Node (决策节点)

Evaluates a condition and navigates to a different branch in the pipeline.

 

At least one Start node and one Interaction Node

 

Start Nodes 

In A pipeline may have multiple Start nodes 

Each node must have a unique name. 

The beginning of a different logical branch

Configuration Properties include: 

1. Name: Used in pipeline calls

2. Call mode: 

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

Configuration Properties:

1.Dynamic Template:

a. true: Template Expression = a variable containing a template name, the name can be determined dynamically during runtime from the Pipeline Dictionary

b. false: The template expression = a path to the template under the templates/default folder

 

Transition Node 

creates a transition between two nodes

by clicking and dragging your mouse between two nodes

 

Executing a Pipeline

1.from the browser via an HTTP(S) request

storefrontURL + PipelineName-StartName?ParmName=ParamVal1&...

2.Call or Jump Nodes 

Just for 'Call mode' = 'Private'

 

Checklist when first pipeline does not work

1. Make sure that you are in Navigator view.

2.Right-click DemandwareServer - Demandware : Active Server & Auto-Upload checked

3. DemandwareServer >Properties >Project references. Check that your cartridges are checked

4. DemandwareServer > Demandware > Change Upload Staging Directory. Target version directory and Active version directory matches.

5.DemandwareServer > Demandware > UpdateServer Configuration. Make sure that the configuration is correct

6. Check your cartridge path

7. Administration > Sites > Manage Sites > Site Genesis >Cache Tab. 

Check if Time to live is 0 and Enable Page Caching is disabled.

8.index your site now. Navigate to Site > Site Genesis > Search > Search Indexes.  Check all checkboxes and click on Reindex

9. Check if your project is configured to build automatically in eclipse as below. Project > Build Automatically

 

The Request Log tool

displays the log for the last request and any request prior during the current session

debug message and error message

 

Call Nodes & End Nodes

Call nodes and End nodes work together to process specific functionality in a pipeline.

 

Call Nodes

Invokes a specified sub-pipeline,

After the sub-pipeline execution the workflow returns to the calling pipeline by means of an End node like a function call where the function might return one or multiple values

A Call node requires only a Pipeline-Start node to invoke.(provided as a fixed configuration value or from a pipeline dictionary key.)

 

 

sub-pipeline

for reusability, defined as Private.

 

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.

 

Jump Nodes

invokes a specified sub-pipeline

After the sub-pipeline's execution the workflow does not return to the calling pipeline.

 

A jump node requires:

1.The name of the pipeline to be jumped to and

2.The name of the pipeline start node to be used

 

This information can be provided:

1.Either as a fixed configuration value OR

2.From a pipeline dictionary key 

 

Default-Start pipeline  jumps to the Home-Show pipeline

 

The Pipeline Dictionary

Is the main data container for each pipeline execution

created & initialized when a pipeline is invoked

remains in memory as long as the pipeline executes

The structure of pdit: is a hash table with key/value pairs

 

The default keys in the pdict: 

CurrentDomain

CurrentOrganization

CurrentPageMetadata

CurrentSession

CurrentRequest

CurrentUser

CurrentHttpParameterMap

CurrentForms

CurrentCustomer

CurrentVersion

 

The pdict is passed across sub-pipeline calls:whenever a call or jump to another pipeline is executed, the same pdict is passed to the invoked sub-pipeline

 

view the values stored in the pdit:

in a debug session (pipeline debugger)

 

Passing Parameters :

In CurrentHttpParameterMap object inside the pdict. 

 

CurrentHttpParameterMap :

an object of type HttpParameterMap

contains a single key => contains multiple values: stringValue,intValue , etc..

 

Troubleshooting with the Pipeline Debugger:

1. Request Log tool

2. Studio Pipeline Debugger

 

Pipeline Debugger :

on the pipeline level, not at source code level.

requires:

1.a running Demandware system

2.a properly configured Remote Server connection

3.create a debug configuration

4. set breakpoints (a semi-transparent green  => a solid green)

 

Demandware Pipelets :

executes an individual business function within a pipeline.

pre-coded pieces of functionality provided by Demandware.

belong to the bc_api cartridge

a published API available under Studio Help menus,

Each Demandware pipelet has documentation on its functionality, input and output parameters. can see this information in the Properties view when the pipelet is selected on the pipeline

 

other types of pipelets from the palette such as:

1. Script: use to invoke a custom Demandware script file

2. Eval: use to evaluate data in the pdict.

3. Assign: use to assign values to specific keys on the pdict

 

ISML - Internet Store Markup Language

extension of .isml

define how data, tags and page markup are transformed into HTML that is sent to the browser, using CSS for page layout and styling.

Demandware 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.

 

Model-View-Controller pattern :

templates =>"view"

pipelines =>"controller" 

DW, Script API =>"model"

 

create an ISML template

File ->New ISML Template

 

ISML Tags and Expressions

ISML Tags : 

1.Demandware proprietary extensions to HTML that   developers use inside ISML templates

2. start with 'is', work together with regular HTML

 

    ISML tags and expressions can be only written in ISML templates

 

ISML tags can be divided into the following groups:

 

HTTP-related :

1.<iscookie>

Sets cookies in the browser

2.<iscontent>

Sets the MIME type

3.<isredirect>

Redirects browsers to specific URLs

4.<isstatus>

Define status codes

 

Flow Control :

1.<isif>

Evaluates a condition

2.<iselse> <iselseif>

Specifying alternative logic

3.when an <isif> condition does

not evaluate to true.

4.<isloop>

Creates a loop statement

5.<isnext>

Jumps to the next iteration in a loop statement

6.<isbreak>

Terminates loops

 

Variable-related :

1.<isset>

Creates a variable

2.<isremove>

Removes a variable

 

Include :

1.<isinclude>

Includes the contents of one template on the current template

2.<ismodule>

Declares a custom tag

3.<iscomponent>

Includes the output of a pipeline on the current page

 

Forms :

1.<isselect>

Enhances the HTML <select> tag

 

Output :

1.<isprint>

Formats and encodes strings for output

2.<isslot>

Creates a content slot

 

Others: 

1.<iscache>

Caches a page

2.<iscomment>

Adds comments

3.<isdecorate>

Reuses a template for page layout

4.<isreplace>

Replaces content inside a decorator template

 

Active Data : 

1.<isactivedatahead>

Allows collection of active data from pages with a <head> tag

2.<isactivecontenthead>

Collects category context from a page for active data collection

3.<isobject>

Collects specific object impressions/views dynamically

 

ISML Expressions

Based on the Demandware Script language.

Demandware Script language is ECMAScript standard.

access to variables, methods and objects is the same as using JavaScript.

embedded inside ${…}

ISML processor to interpret (解释) the expression prior to(优先于) executing an ISML tag

access to data by using dot notation, e.g. :${pdict.Product.UUID}

 

The difference between this ISML expression and one used inside a pipeline node property (i.e. decision node) :

in ISML: MUST specify the ${pdict.object.property} if you want to access a value in the pdict

in pipeline node properties: the pdict is implicit(隐式) and the ${} not used : e.g. Product.UUID

 

 

ISML expressions access Demandware Script classes and methods:

available implicitly: 

1. TopLevel package: session. getCustomer()

2. dw.web package: URLUtils.url(), URLUtils.webRoot()

fully qualified:

1. Other packages. 

 

ISML expressions allow complex arithmetical:

  ${pdict.Product.getLongDescription() != null}

 

IMPORTANT NOTE

closing </> tag , it is best practice to always use a closing tag.

 

<isset>

Creating and Accessing Variables

required attributes: name, value.

default scope : session

Example:

    <isset

        name = "<name>"

        value = "<expression>"

        scope = "session"|"request"|"page"

    >

 

value attribute: hard-code or ISML expression

scope attribute: the level of accessibility of the variable

three developer available levels: session, request, page

 

Variable Scope :

from widest to narrowest access:

Global: 

          accessible : the dw.system.OrganizationPreferences class. 

  Available to:  any site within an organization.

Site : 

accessible : the dw.system.SitePreferences class

Available to: any pipeline executing as part of a site.

session : 

available:  through the whole session.

pdict :

available : while a pipeline executes

encompass (包含) : multiple requests , (ICN)

request :

available : a request-response cycle

page : 

available : for a specific page , and its locally included pages.

slotcontent: 

available : only in the rendering template for a content slot

<isloop> variable: 

available : inside the loop

 

Session variables:

multiple requests within a customer session

Any variable added to the session scope becomes a custom attribute of the session object:

It is not a standard attribute

Must be accessed with the 'session.custom' qualifier

${session.custom.myVar}

 

Request variables : 

available :  A request variable is available only for a single browser request-response cycle, it does not persist in memory for a subsequent(后来的) request

Must prefix request variables with a qualifier 'request.custom' when accessing them:

${request.custom.myRequestVar}

 

Page variables : 

available :  current ISML page,  limited to the current template, and any locally included templates, 

They are accessed WITHOUT a prefix:

${pageVar}

 

Setting and retrieving variables:

1.In the template, create a new variable called sessionVar with hardcoded text as the value and print the value to the page:

<isset name="sessionVar" value="${123}" scope = "session"/>

2.The value of the sessionVar variable is:

${session.custom.sessionVar}<br/>

3.Increment the variables by using syntax like

value="${request.custom.requestVar + 1}"

 

Reusing Code in Templates :

Four tags for reusing code in ISML templates:

1.<isinclude> 包含

2.<isdecorate> 装饰

3.<ismodule> 自定义标签

4.<iscomponent> 

 

Reusable code for these purposes:

Saves time 节约时间

Reduces the likelihood of errors 减少可能的错误

Minimizes the chore of updating pages 最小化更新页面的工作

Helps to ensure a consistent look and feel 帮助确保一致性

 

<isinclude> Tag :

Embed an ISML template inside the invoking template

 

Two types of includes: 

1. Local Include  – allows you to include the code of one ISML template inside of another while generating the page

2. Remote Include  – allows you to include the output of another pipeline inside of an ISML template. The primary purpose for using a remote include is for partial page caching. 

 

 

Local Includes

Syntax: 

<isinclude template="[directory/]templatename" />

no need to add the '.isml' extension

 

Local Includes Example 

Template 1:

<h1>My Template</h1> <br/>

<isinclude template="extras/calendar" />

Template 2 (calendar.isml)

<h1>Included template</h1>

 

IMPORTANT NOTE

1. Local Include - All variables from the including template are available in the included template, including page variables.

2. Remote Include -Pdict and page variables from invoking template are NOT available in the included template. The only variables available to a remotely included pipeline are session variables.

3. Includes from another server are not supported.

 

Remote Includes: 

will invoke another pipeline which returns HTML at runtime.

syntax : 

<isinclude url="pipeline_url" />

     call a pipeline without passing URL parameters:

<isinclude url="${URLUtils.url('Product-IncludeLastVisited')}" />

passing URL parameters:

<isinclude url="${URLUtils.url('BrowseCatalog-Hotdeals', 'catalogCategoryID',  'Storefront')}"/>

 

<iscomponent> tag : 

implements a remote include , pass as many attributes,  without having to use the URLUtils methods: 

<iscomponent

pipeline = <string> | <expression>

[locale = <string> | <expression> ]

[any number of additional arbitrarily named parameters]

/>

example:

<iscomponent 

pipeline ="Product-Show" 

productid="1234" 

name="Wide-screen television"

/>

 

<isdecorate> Tag : 

Reusing Code in Templates 

lets you decorate the enclosed content with the contents of the specified (decorator) template. 

A decorator:  an ISML template that has html, css, and overall design of a page. It has the tag <isreplace/> identifying where the decorated content shall be included.

Typically, only one tag (<isreplace/>) is used in the decorator template. However, multiple tags can also be used. If the decorator template has multiple <isreplace/> tags, the content to be decorated will be included for each <isreplace/> tag.

 

Template using a decorator :

<isdecorate template="[Decorator template name]">

...My content...

</isdecorate>

 

Decorator template :

<html>

<head>…</head> 

<body>

<isreplace/>

</body>

<html>

 

<ismodule> Tag: 

Creating Custom Tags

There are 3 key isml files required for creating and using a custom tag:

 

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>

 

Conditional Statements and Loops :

<isif condition=”${ISML expression evaluated}”>

Do something here if true.

<iselseif condition=”${check another condition}”>

Do something if this one is true.

<iselse>

If none of the above conditions are true, do this.

</isif>

 

<isloop> tag :

loop through the elements of a specified collection or array

you can list data like categories, products, shipping and payment methods. 

An <isloop> statement can be nested in one another.

 

Supporting tags: 

<isbreak> :

can be used within a loop (defined by an <isloop> tag) to terminate a loop unconditionally. If <isbreak> is used in a nested loop, it terminates only the inner loop.

<isnext> :

to jump forward in a loop. Jumping forward within a loop to the next list element of an iterator. This tag affects only the iterator of the inner loop. 

syntax : 

 

<isloop> tag syntax :

<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>

 

items (iterator)

returning an object to iterate over. Attributes iterator and items can be used interchangeably

 

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.

 

status variable accesiible properties:

count : The number of iterations, starting with 1.

index : The current index into the set of items, while iterating.

first : True, if this is the first item while iterating (count == 1).

last : True, if this is the last item while iterating.

odd : True, if this is the last item while iterating.

even : True, if count is an even value.

   example: <isloop 

... status="loopstate" ...

/>

use:  <isif condition="loopstate.first">

 

 

 

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. 

 

end

Expression specifying an end index (inclusive). 

 

step

Expression specifying the step used to increase the index. If step is smaller than 1, 1 is used as the step value.

 

Using Loops

display the products in the cart:

<isloop

items="${pdict.Basket.getProductLineItems()}"

var="productLineItem">

${productLineItem.product.name}<br/>

</isloop>

 

Content Slots :

A content slot is an area on the page where a merchant defines content to display based on certain qualifiers or rules.

 

Found slots on a page : 

Storefront  Toolkit > Content Information tool

 

Content slots(内容槽) vs. Content Assets (内容资源)

Slots are different from content assets in several aspects:

1. Slots  under: Site > Online Marketing > Content Slots. 

  Assets under: Content section

2. Slots are controlled by campaigns: 

start/end dates, customer groups, source codes, coupons and rank are qualifiers that affect the appearance of a slot. Content Assets do not have such qualifiers.

 

Creating Content Slots

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:

1. Global slots: can appear on any page.

2. Category slots: appear on category-specific pages since they depend on the category id.

 

Slot display content types:

1. One or many products selected by the merchant 

2. Category attributes (images or other visual) 

3. Content assets from the content library 

4. Static HTML and images from the static library 

 

Creating Content Slots - Developer Tasks

 

1.inside a template using the <isslot> tag

a. Global slot:

<isslot id="header_banner" description="…"    context="global" />

b. 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.Achieves by automatically scanning any template for the use of the <isslot> tag

 

2. Creating the Slot Rendering Template

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:

<div class="htmlslotcontainer">

<isif condition="${slotcontent != null}">

<isloop items="${slotcontent.content}" var="markupText">

  <isprint value="${markupText.markup}" encoding="off"/>

  </isloop>

</isif>

</div>

 

Every slot is rendered by a system pipeline inside the core cartridge: _SYSTEM_Slot-Render. 

It uses the slot configuration that the merchant creates and provides all the configuration information to the rendering template by means of the TopLevel.global.slotcontent constant (常量).

只有slot渲染模板会使用这个常量

 

The rendering template code checks that the slotcontent is not empty:

<isif condition="${slotcontent != null}">

 

Then it loops through the slotcontent.content 

<isloop items="${slotcontent.content}" var="markupText">

<isprint value="${markupText.markup}" encoding="off"/>

</isloop>

 

Inside the loop the code uses the <isprint> tag:

<isprint value="${markupText.markup}" encoding="off"/>

Using the encoding="off" setting allows the HTML snippet to be generated without encoding, so that the browser renders it correctly. 

 

Creating Content Slots - Merchant Tasks

1. under : Site > Online Marketing > Content Slots

2. The merchant selects an existing configuration or clicks New to create a new one.

3. enters an ID, enables the slot, provides other relevant information. select content type.

4. select rendering template (existing or new one developer creates) , rendering template under slots/html dir.

5. provide a schedule

 

Using Content Link Functions

1. $staticlink$ - Creates a static link to an image

2. $url()$ - Creates an absolute (绝对链接) URL that retains the protocol of the outer request. (不包含协议)

3. $httpUrl()$ - Creates an absolute URL, but with the http protocol.

4. $httpsUrl()$ - Creates an absolute URL, but with the https protocol.

5. $include()$ - Can be used to make a remote include call (relevant for caching purposes)

 

example: create a hyperlink to the Page-Show pipeline passing cid=2-day-shipping-popup in the query string:

href="$url('Page-Show', 'cid', '2-day-shipping-popup')$"

 

Demandware Script (DS)

1. server-side language

2. based on JavaScript, which is standardized as ECMAScript.

3. write in:

pipelines inside Decision nodes

in ISML templates for expressions 

inside <isscript> tags

inside Script pipelets ( most extensive ) 

 

API Packages 

1. cannot inherit from these classes or packages (Demandware Script API )

2. can only use the properties and methods of these classes (Demandware Script API ).

 

TopLevel  package

1. default package, no need to be imported in scripts.

2. provides classes and extensions:  Error, Date, Function, String, Math, Number, XML.

 

3.TopLevel.global class : contains many of the common variables and constants used in pipelines and scripts, 

such as: 

   a. Constants: PIPELET_NEXT , PIPELET_ERROR

indicate (表明) the result of a script pipelet and determine which exit the pipeline takes after pipeline execution

b. Properties: customer, request , session

get access to the current customer and the current session

 

IMPORTANT NOTE 

1.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 can use: ProductMgr.getProduct(String id) to get a product using a unique identifier. 

 

Using Demandware Script in ISML

1. using the <isscript> tag. 

2. you can fully qualify every class you want to use or you can choose to import any packages at the top of the script

for example: get the root category of a current site’s navigation catalog as well as getting the category named 'sale' using Demandware script

<isscript>

importPackage(dw.catalog);

var siteCatalog = CatalogMgr.getSiteCatalog();

</isscript>

 

Script Pipelets

1. have an extension of .ds

2. stored in the /cartridge/scripts directory.

3. can have input and output parameters for data manipulation.

4. When create a new script file, the file will be preconfigured (预配置) for scripting. 

 

5. Input & Output Parameters:

configured within the script text.

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:

*@input ProductID : String 

*@output Product : Object

commented out with a *- so you will need to delete the minus sign for the Demandware application to read the parameters

 

input/output data types:

TopLevel package classes: String, Number, Object, etc.  any other data type as long as you fully qualify it: dw.catalog.Product.

@output Subscription : Object

@output Product : dw.catalog.Product Must fully qualify this output type

 

Importing

Base syntax: 

importPackage ( dw.system );

 

import a single class:

importClass( dw.system.Logger );

 

import a custom script from the same cartridge :

importScript("common/libJson.ds");

 

accessing a script in another cartridge:

make sure you specify the cartridge prior to the script name as the system will not look for further scripts with the same name in the cartridge path:

importScript( "<cartridge name>:[folder/]utilities.ds" );

 

Using the Script Editor

1. turn on line numbers: right-clicking the gray column on the left side , selecting the Show Line Numbers checkbox

2. auto-complete: Ctrl+Spacebar

 

Scripts and Cartridge Path Relationship

1. scripts :  NOT searched using the cartridge path . A script is expected to(希望) be in the cartridge of the current executing pipeline unless the cartridge is explicitly stated in the ScriptFile configuration property. In which order the solutions cartridge appears in the path is not relevant from the point of view of script access. 

2. pipelines, templates: searched using the cartridge path, the order of cartridges is relevant for executing pipelines and templates, the first matching file found is used.

 

The ScriptLog Output

1. ScriptLog :  Every script pipelet used in a pipeline comes with a default Dictionary Output property.

2. using TopLevel.global.trace(msg : String , params : Object ...) method write debug or error message to the pipeline is not recommended. Suggest use dw.system.Logger API to write.

 

Script Debugging

1. you must first create a script debug configuration.

2. you will need to add breakpoints in your script files.

3. it is possible to run the script debugger along with the pipeline debugger.

 

Resource API and Resource Bundles (翻译功能)

1. Using resource bundles to avoid hard-coding text strings that become visible to the user 

2. with a .properties extension 

 

IMPORTANT NOTE

1. Property files can be suffixed by“Bundlename_<<locale_id>>.properties” 

2.“<<locale_id>>” stands for a specific locale term other than the default locale. For example, “de” or “en” (or locale plus country like “de_DE” or “en_GB”).

3. The resource bundles contain key=value pairs where the key might be compound 复合型key : (key.subkey) and the value is a hard-coded string

4. stored in each cartridge:  /templates/resources directory

5. via dw.web.Resource.msg(key : String , bundleName : String ,defaultMessage : String ) method . for exp:

${Resource.msg('account.header', 'account', null)} 

second parameter points to the account.properties file

6.  via dw.web.Resource.msgf(key : String , bundleName : String , defaultMessage : String , args : Object...)

specify a key with placeholders which can be dynamically replaced by the parameters specified 

in template: 

${Resource.msgf('singleshipping.wishlist', 'checkout', null, owners.get(addressKey).profile.firstName )}

in resource file:

singleshipping.wishlist={0}\'\'s Wishlist

 

Forms Framework

1. simplify form display and processing set.

2. you can control how consumer-entered values are validated by the application

3.  rendered on a browser and possibly stored on a server.

 

You need the following four files:

1.An xml form to define and store the metadata

2.A pipeline that will validate and process the form

3.A properties file that contains externalized form labels and possible error messages

4.An ISML template that will display the form to the user

 

There are 3 objects that interact:

1.XML metadata file: located in the cartridge/forms/default directory. It describes the fields, labels, validation rules and actions that apply when the field is used in an ISML template.

2.ISML template: it uses the form metadata fields and actions to show an HTML form to the user.

3.Object (optional): this object represents a single system or custom object in the pdict, and it can be used to pre-fill the metadata file as well as to store submitted form data to the database.

 

XML Metadata File

1. identify which fields a user will need to enter

2. identify what actions can be taken when implementing a form

 

The form metadata file uses the following XML elements:

 

1. form

Required: top level tag that contains all other elements inside <form>…</form>

 

2. field 

Required: Defines data field with many attributes

 

3.options

Use as a child element inside a field to pre-fill multiple options like months, days, etc

 

4. option

Use as a child element inside an options element to specify a single option

 

5. action

Required: Defines a possible action the user might take on the form

 

6. include

Allows inclusion of one form metadata definition into another.

 

7. list

Allows inclusion of several items (i.e. collection of addresses) as a single field

 

8.group

Allows grouping of elements to be invalidated together

 

The field element may use the following attributes:

1. formid

Required: unique ID to identify the field for ISML templates and pipelines.

2. type

Required: data type for field 

3. label

Usually a key to an externalized string in the forms.properties resource bundle.

4. description

Description for field, might be used in tooltips.

5. min-length, max-length

Restricts(约束) the field length for data entry.

6. min, max  

Valid range for integer, number and dates.

7. range-error

Message shown if value provided does not fall within the specified range.

8. regexp

Regular expression for string fields: email, phone, zipcode, etc.

9. parse-error

Message shown when the data entered does not match the regex. Usually a key to an externalized string.

10. mandatory

Field is required via server side validation when true.

11. missing-error

Message shown if the primary key validation error is generated in a pipeline.

12. value-error

解释 if a primary key validation error is generated in a pipeline.

13. binding

Used to match field to a persistent object attribute.

14. masked

Specify # of characters to mask.

15. format

Format for display of dates, numbers, etc.

16. whitespace

Specify whitespace handling (none or remove).

17. timezoned

Optional flag for date objects (true or false).

18. default-value 预先定义值

Pre-defines a value for a field.

19. checked-value  

Value when field is checked in a form.

20. unchecked-value  

Value when field is unchecked in form.

 

Here is an example of a simple form metadata file:

 

IMPORTANT NOTE

1. best practice: use lower-case letters when naming your xml forms(小写字母命名). 

2. Pipelines also xml, use  camel-case naming

 

ISML Form Template

1.  with the same tags needed for a valid HTML form: <form>…</form>

 

2. specify an Interaction Continue Node for the form action to post : 

<form action="${URLUtils.continueURL()}" method="post" name="SendToFriendForm" id="SendToFriendForm">

 

dw.web.URLUtils.continueURL(): ensures that the form gets submitted back to the Interaction Continue Node that displayed the form template.

 

3. When creating input fields, you must use the object: pdict.CurrentForms.<form metadata file>.<formid> to reference the specific formid in the form metadata.

 

4. SiteGenesis <isinputfield> custom tag facilitates(促进) the creation of form fields.

e.g  Show the fname field from the newsletter.xml file as a text field in an ISML template

 

<isinputfield formfield="${pdict.CurrentForms.newsletter.fname}" type="input">

 

The custom tag will use the fname formid

build an HTML label using the forms.properties file to pull the text for the forms.contactus.firstname.label key

 

Creates an HTML input field to the right of the label with the necessary client-side JavaScript to enforce required fields

 

You can modify the behavior of the <isinputfield> tag since it is a custom tag implemented in the SiteGenesis cartridge.

 

5. 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}"/>

 

pdict.CurrentForms.newsletter.subscribe.htmlName : 

refers to the htmlName property of the action subscribe in the form metadata

In the debugger you can view the value of this property at runtime: dwfrm_newsletter_subscribe.This value identifies a specific action for a specific form, which is necessary when the pipeline ICN determines which form action to process.

 

Form Pipeline Elements 

1. ClearFormElement 清空表单

pipelet to clear an existing form object in the pdict using a specified form metadata file.

2. InvalidateFormElement 废弃表单元素

invalidates the specified FormElement

3. ICN 

show the ISML form, and to perform server-side validation

4. Transitions 

   match actions from the form metadata

    5. A “next” transition 

goes back to the ICN to handle validation errors

 

To create a form using the form framework, follow these steps:

1.Create an xml metadata file that will hold your form data

2.Create an ISML template that will display a form to a visitor.

3.Create a pipeline that includes at minimum:

a)Start node

b)ClearFormElement pipelet that clears the form object next time you run the pipeline again.

c)Interaction Continue node that links to the ISML template you created in step 2.

d)Transition nodes to handle the following scenarios

 

Custom Objects

Custom objects (COs) extend the Demandware data model: they are basically a new table in the database where you specify the primary key and storage attributes (columns) that suit your business needs.

 

IMPORTANT NOTE

1. 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).

2. Custom objects searches can be slow if the data is large. You should consider data growth and cleanup in your COs.

 

Custom object data types

1.  created at the organization level 

available for use in all storefronts within the organization

2. two different Business Manager modules to define and manage your custom objects : 

a. Custom Object Definitions:

allow : naming, primary key and column specification. 

under : Administration ⇒ Site Development

b. Custom Object Editor

allow:  instance creation and editing

under: Site - <site> ⇒ Custom Objects ⇒ Custom Object Editor

 

defining the CO:

1. specify the storage scope of the instances, The CO type itself is always available to the entire organization

a. site

site custom objects are created by one site and cannot be read by another

b. organization

Organization custom objects can be used by any site.

2.  specify if you want CO instances to be replicable

this means they can be copied from Staging to Production as part of the replication process.

 

Using Script to create Custom Object Instances

Using Demandware Script to Create Custom Objects

following classes in the dw.object package:

1. CustomAttributes: attributes defined by a user in the Business Manager to extend a system object or CO. Accessible via the syntax: co_instance.custom.attribute

2. CustomObject: represents an instance of a CO

3. CustomObjectMgr: allows the creation of CO instances

4. PersistentObject: allows persistent (持久) storage

5. ExtensibleObject: allows custom attributes to be added (可扩展)

 

This is the inheritance tree for the CustomObject type:

1. Object –> dw.object.PersistentObject -> dw.object.ExtensibleObject  -> dw.object.CustomObject (or dw.object.SystemObject)

 

2. COs are persisted in the database and can have custom attributes added by an administrator or programmer in Business Manager. 

 

3. 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.

 

CustomObjectMgr class:

allow : creation of an instance of a CO by providing the CO type and the primary key

a. CustomObjectMgr.createCustomObject("NewsletterSubscription", UUIDUtils.createUUID());

       This will create an instance with a system generated, unique PK

 

b. 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.

 

Implicit Database Transaction Handling (显式数据库事物处理)

 

Database transaction two ways:

1. Implicit 显式

a transactional pipelet automatically begins a transaction. The transaction is automatically committed to the database when the pipelet returns PIPELET_NEXT, otherwise the transaction is rolled back.

 

the pipelet 'Transactional' property  = true

 

 

2. Explicit 隐式

the transaction is controlled via properties of the transition nodes in the pipeline

 

Create a custom object programmatically

1.Create a custom object type in BM before creating a custom object programmatically. 

2.Create a script that uses the dw.object.CustomObjectMgr class to create a custom object:

importPackage( dw.system );

importPackage( dw.object );

function execute( args : PipelineDictionary ) : Number

{

var co : CustomObject = CustomObjectMgr.createCustomObject("NewsletterSubscription", args.email);

co.custom.firstName = args.firstName;

co.custom.lastName = args.lastName;

args.subscription = co;

return PIPELET_NEXT;

}

 

custom qualifier: 

must use for all custom attributes. since the class dw.object.CustomObject does not have any standard attribute named firstName.

 

3.Edit the properties of the pipelet:

a)Make it Transactional so it commits to the database.

b)Assign all the corresponding form values to the pipelet inputs.

c)Assign the subscription output to a Subscription object.

d)Verify that all properties are correctly defined:

 

4.Modify the subscription confirmation template to use the Subscription object from the pdict:

${pdict.Subscription.custom.firstName}

 

Troubleshooting:

a.Check to see if you imported dw.object package

b.Check to see if you have marked the script node as Transactional

c.Re-check the configuration of the script in Step 3d

d.Check if the NewsletterSubscription Custom Object type exists in the BM (‘N’ capital, ‘l’ small, ‘S’ capital).

e.Also check if string attributes “firstName”, “lastName” and “email” exist in it and are a part of an Attribute group.

 

Custom Logging 自定义写日志

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 messages at different levels of granularity(粒度). 

 

1. The severity levels :

Debug < Info < Warn < Error < Fatal

a. If custom logging is enabled for a certain severity level, then it is enabled for higher severity levels as well.

b. Fatal and Error are always enabled and cannot be turned off

 

2. for categories 

a. the programmer can define as many levels of categories and subcategories as needed

b. Demandware does not impose(强行) a certain categorization; you decide how you want to organize your logging categories

For example:

product

product.import

product.import.staging

 

If Warn logging is enabled for "product": 

>Warn, Error and Fatal errors are logged for "product" and all its sub-categories.

 

If Warn logging is enabled for "product" and Debug for "product.import"

>Warn, Error and Fatal messages are logged for "product" and all its sub-categories.

>Debug, Info are logged for 'product.import' and all its sub-categories.

 

3. To write to a custom log

a. use the dw.system.Logger.getLogger() factory method.

b. creates a Logger object for a specified category:

var logger : Logger = Logger.getLogger("category");

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) {

logger.warn("error description: {0}", e.causeMessage );

return PIPELET_ERROR;

}

c. You can use the Logger object to write a message for a specific severity level: Logger.error(String msg).

 

d. these messages are not localized since they are read internally by site administrators, but they can be.

 

4. Enabling Custom Logging

under : Administration => Operations => Custom Log Settings

 

Data Binding and Explicit Transactions

数据绑定和显式事务

 

Data Binding with Forms and Objects 数据绑定到表单和对象

1. The Demandware forms framework supports binding of persistent(持久) objects to form fields by automatically updating a persistent object with form data without having to issue an insert statement or calling a Demandware API. 

DW的表单框架支持绑定持久对象到表单原件。自动用表单数据更新持久对象,不需要插入语句或者调用DW API。

 

2. The reverse mechanism is also supported: pre-populating a form object with data from a persistent object.

逆向机制也是支持的: 用数据库里的持久对象,预先填充表单对象。

 

3.The object that is bound to the form must be a persistent object (system or custom), and must be available in the pdict. 

对象需要被绑定到表单的必须是持久的对象(系统 或者 自定义), 而且必须在pdict中可以使用

 

4. The form metadata must have field(s) with the binding attribute specified.

表单的metadata 必须将字段指定binding attribute才能使用这个机制

 

5. The field formid attribute is not used to make the match; only the binding attribute identifies what fields match between the form and the object.

formid属性不用于做匹配。只有binding属性定义哪个字段在form和object之间匹配。

这是因为

 

UpdateObjectWithForm  Pipelet 

allow: updates an existing persistent object with data from the form

requires : object to update and the form object both available on the pdict. 

transactional: It is transactional by default since the object to be updated must be a persistent object.

example: define the properties of the pipelet using the newsletter form and NewsletterSubscription object

Form: CurrentForms.newsletter

Object: Subscription

 

process step: 

1. inspect(检查) the CurrentForms.newsletter form in the pdict, and try to match every field with a binding attribute to a column in the object called Subscription.

2. Subscription must be an instance of NewsletterSubscription that was placed in the pdict by either creating a new instance (using CreateCustomObject pipelet) or by retrieving an existing instance (using SearchCustomObject pipelet).

3. If the Subscription object is null, or not an instance of NewsletterSubscription CO, or the form is not in the pdict, the pipelet will fail and the transaction will be rolled back. 

4. If the pipelet is successful the transaction will commit.

 

UpdateFormWithObject  Pipelet

allow: updates a form with data from an object

requires : the form to update and the object to be both available on the pdict

transactional:  It is not transactional since the updated form lives in the pdict scope, not in the database.

Notice: a form group may be updated with an object: as long as the bindings match, just that part of the form will be updated.

example:  profile.xml form has a customer group that will be updated with the existing profile data from the logged in customer.

Form: CurrentForms.profile.customer

Object: CurrentCustomer.profile

 

Explicit Transaction Handling 显式事务处理

 

1. use in some circumstances(情况): the transaction spans(跨越) several pipelets or steps, in this case you need to decide where the transaction begins and ends. 

 

2. implemented : at the pipeline level by changing the 'Transaction Control' property of a transition node or connector node.

You Can use:

a. Begin Transaction

b. Commit Transaction

c. Rollback Transaction

 

3. This can be used to override(覆盖) the built-in(内置) implicit transaction in order to group changes that need to be an atomic transaction (原子事件).

 

Data Intergration 

1. two types of data integration:

a. Simple Feed Integration

b. Web Services

 

Simple Feeds

1. allow: exchanging files on a File Transfer Server

 

2. supports the protocols

a. WebDAV (HTTP and HTTPS) :  

HTTP: for development/testing purposes only

HTTPS: an SSL-certificate from a Demandware accepted Certificate Authority (CA) needs to be installed at the File Transfer Server. The list of accepted CAs is available at Demandware’s Customer Central.

b. SFTP

 

3. File Transfer Server

a. Hosted by the customer or another 3rd party.Demandware does not offer hosting File Transfer Servers.

b. The WebDAV access to certain folders on a Demandware instance cannot be used for that purpose.

 

    4. File Format

a. Standard Demandware import/export format: XML files the schema definitions (XSD files) can be downloaded from Customer Central

b. how to get the samle file: set up the data as desired in Business Manager, run an export, use the exported file as a template

c. file type:  alternatively(选择性) be provided in gzip format.provide the file with extensions .xml.gz or .csv.gz at the File Transfer Server and adjust the file matching rule.

d. The validation and import processes will automatically unzip the files during processing

 

5. Jobs

a. three types: 

scheduled : 

schedule jobs to run according to a schedule or for one time only.

import/export 

and batch

b. detecting (监测)

notification of job status and recovery from failed jobs by email

job failure rules: for automatically re-run

retry parameters : number of retries 

   c. jobs execute on:

global (or organization) level and jobs that execute only on a site level 

under Administration > Operations.

 

Import into Production

1.load all feeds that can be previewed into instance Staging for approval and use Demandware’s data replication feature for promotion to Production. Data replication also comes with rollback functionality.

 

2. Consider the different Catalog import modes:

A+a  an object with a new attribute

B –a  an object with an attribute removed.

C  an object left unchanged

D  a new object

FΔa  an object with an attribute value that is changed

You can overwrite the XML file import mode for a single element, but only to specify DELETE:

<product product-id="12345" mode="delete"/>

 

3. two pass import

a. during the first pass objects are updated

b.  relationships between objects are updated

 

Simple Feed Cartridges:

1. int_simplefeeds

function : Implementation of generic logic

assigned : e storefront site and the BM site

Modification: Custom_FeedJobs pipeline is necessary to use the feed configuration custom object. Do not modify other code.

2. test_simplefeeds

function:  help troubleshooting WebDAV or SFTP connection issues

trigger :  a Simple Feed Integration job from the storefront during development

assign :  must not be assigned to a site on Production systems.  It may be assigned to the storefront site on sandbox instances if the storefront is password protected.

 

WebDAV 

The only protocol for:  (It is the only protocol that works on both directions.)

1. DW =>access file external.

2. external system => push file to DW

 

SFTP

1. external system CANNOT access files in DW

2. DW can access an external SFTP Server

 

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.

 

Web Services

1. use for : real-time data integration with a 3rd party system or your own backend

2. what is web service? 

A web service is a remote service created to expose(暴露) data in a database, or the result of a calculation. It is a remote procedure call that goes through HTTP. 

 

3. supported protocols

many. we will focus on SOAP style web services

 

Generating WSDL Javadocs

you can generate Java classes and javadoc to help you write the Demandware Script code:

1.Download the Axis 1.4 and Xerces jar files from Apache.

 2.Create an AXISCLASSPATH environment variable to point to the

3. downloaded jars.

4. Generate Java stubs using the command:

Java –cp

%AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java

--noWrapped --all --package currencyconvertor 

CurrencyConvertor.wsdl

5. Generate the Javadoc for use in coding:

javadoc -d currencyconvertor\javadoc currencyconvertor

 

WSDL File

1. A WSDL file is a document that describes a web service. It specifies the location of the service and the operations (or methods) the service exposes.

2. 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. 

3. You will need to write a script file for accessing those classes using the Demandware API.

 

Integrate a web service

1.Get the WSDL file for the web service you wish to invoke.

2.Place the WSDL file in the webreferences folder in your cartridge.

3.Using a script pipelet, add the following to your script:

a. Import the dw.rpc package

b. Create a webreference object (example below):

Var webref : WebReference = webreferences.WSDLFileName

c. Get service stub object (example below):

var stub : Stub = webref.defaultService

4.Invoke the methods/properties from the web service you need. Generate Javadocs from the WSDL if you need help invoking the remote method(s).

 

Integration Framework 集成框架

 

使用原因:

The growing complexity of the batch processes required to operate a shop, have brought in some cases the existing implementation to its limits. On the one hand side because of the growing number of batch components (Jobs) and on the other hand due to lacking monitoring and notification capabilities.

日益增长的批处理执行于一个商店,带来了某些情况下实现的局限性,一方面因为Jobs数据增长,另一方面因为缺少监控和通知功能。

 

解决方法:

This concept(概念) will define a general way how workflows and its components(组件) need to be built so that a common infrastructure(基础设施) can provide facilities for monitoring(监控工具), logging(日志), configuration(配置), scheduling(计划任务) etc. One such framework which allows us to do so is Integration Framework. It is nothing but a combination of cartridges(组合cartridges), preferences(参数设置), custom objects (自定义对象) and meta-data which together can help create a workflow and monitor it. The first step towards using Integration Framework is installing it. 

 

General concept 基本概念:

Every workflow that needs to be executed is modelled as a WorkflowSchedule (工作流程安排), containing main information about frequency, run times, enablement, file log level, etc.

 

Every WorkflowSchedule consists of :

1. Simple WorkflowComponentInstances 

a. created from:  

the existing WorkflowComponentDefinitions

从已有的WorkflowComponentDefinitions流畅组件定义中创建一个组件实例

b. describing : the steps within the workflow and their individual configurations

描述:工作流畅中的步骤,还有他们个体的配置

c. For recurring(循环) schedules :

the schedule itself and its components are cloned for each schedule run.

每个schedule 在循环的时候还有它的组件会被克隆

 

(在Dw术语中的定义) a WorkflowSchedule consists of

1.  a custom object defining the workflow

一个自定义对象定义workflow

2.  a number of job schedule definitions in the Demandware BM which check for workflows to execute on a regular basis

很多job schedule 定义,在DW BM中,用来检测workflow定期执行

 

 

Scheduled Job Configuration

Standard Demandware jobs are used to trigger the workflow engine. All other calculation is done by the framework itself. This allows for example the displaying of upcoming workflows even days in advance.To setup a scheduled-Job:

标准DW jobs用于触发workflow引擎。所有其他的计算是框架本身来完成的。

这允许显示预先显示未开始的workflow,来建立一个schedule-job:

1. Navigate to Administration -> Operations -> Job Schedules

2. Create a new or edit an old Schedule

3. Set the Execution Scope to either ‘Sites’ or ‘Organization’ depending on the Scope your pre-defined Workflow-Schedule run in. If your Workflow-Schedule should run in both scopes, please create a Scheduled-Job for each Scope.

4. Make sure that pipeline ‘Workflow’ and start node ‘Start’ are already pre-configured.

5. The Provided parameter‚ JobId, associates to a workflow component with the job which triggers the frameworks processing engine. This JobId is used internally by the Workflow pipeline to be able to identify the job that invoked it.

 

 

Monitoring:

A monitoring cockpit(驾驶舱) allows viewing the schedule of the current day as well as the schedule for a given date. For the selected day a list of Workflows that are scheduled is shown as well as their components are shown. All of them state their name, the current status and the status message.

 

List of out of the box components

 

Standard Components Import标准组件导入

The component  allows importing any system or custom object from a designated local or remote directory (relatively to IMPEX/) via XML-Files which corresponds (符合) to a specific naming pattern.

 

Standard Components-Download Files 

Allows you to import from a designated WebDAV or(S)FTP location into Demandware

 

Catalog export

allows exporting of aspecific Catalog into a designated local directory (relatively to IMPEX/).

 

Order export

allows exporting orders(all or confirmed and paid) to a designated local directory (relatively to IMPEX/).

 

Price-Book export

allows exporting of a specific Price Book  into a designated local directory (relatively to IMPEX/).

 

Price import

allows importing Price-Books from a designated local directory (relatively to IMPEX/) via XML-Files  which corresponds to a specific naming pattern.

 

Import slots

allows importing of data from a designated local directory (relatively to IMPEX/) via XML-Files which corresponds to a specific naming pattern into a specified library and in a specified mode.

 

Various Rebuild functionality

To rebuild Search / Availability / ActiveData / Redirect/ Suggestions / Synonyms Indexes

 

Time condition

allows ensuring that the workflow will not be continued in case a configured time is in the past or that the execution will be put on hold until a certain time is reached. This can be useful in case a replication or other workflow needs to happen before a certain point of time in order to not impact the production system performance.

 

Date condition

ensuring that the workflow will not be continued in case a configured date is in the past or that the execution will be put on hold until a certain date is reached. This can be useful in case a replication or other workflow needs to happen before a certain date in order to not impact the production system performance

 

Date-Time condition

allows ensuring that the workflow will not be continued in case a configured date and time is in the past or that the execution will be put on hold until certain date and time are reached. This can be useful in case a replication or other workflow needs to happen before a certain time in a certain day in order to not impact the production system performance.

 

Workflow clean-up

allows the removal of old custom objects which were created through the workflow framework.

 

Clean-up files

allows the removal and archive of old files in specific folders

 

Transfer to FTP

allows the copy of files from a local directory (relatively to IMPEX/) to a FTP-Location

 

Transfer from FTP

allows the copy of files to a local directory (relatively to IMPEX/) from a FTP-Location.

 

Rebuild indexes

Allows the rebuilt of the configured indexes. This component can be useful after the import of a catalog for example.

 

Deconstructing SiteGenesis (解析SiteGenesis)

The main pipelines used for generating storefront pages are:

1. Search-Show 

2. Product-Show

3. Page-Show

4. Cart-Show

5. Account-Show

 

In the past the first 3 pipelines only used to support SEO friendly URLs :

1. Search-Show with CategoryID

2. Product-Show with ProductID

3. Page-Show for Content Assets

 

customizable URL layout:

under: Site – Site Preferences – Storefront URLs.

setting:  locales(语言), Catalog URLs(目录), Content URLs(内容) and Pipeline URLs

 

SiteGenesis Page Deconstruction Tools:

Toolkit Page Information

only accessible in staging, development, and sandbox instances.

 

Storefront Files 前端文件

1. htmlhead.isml, htmlhead_UI.isml, footer_UI.isml

   contain all of the CSS, jQuery libraries, and js files.

2. app.js

Contains the JavaScript for client-side storefront event handling

 

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.

确定ISML模板可以包含的资源目的在于支持拓展UI功能,在这些情况下,那些指定的包含可以删除,而单个的包含到<TEMPLATE_NAME>_UI.ISML.一个空白的<TEMPLATE_NAME>_UI.ISML被创建在核心内,作为一个空白文件确保核心没有被破坏,然后<TEMPLATE_NAME>_UI.ISML文件用Rich UI创建,在Rich Ui版本中。所有指定的元素需要被包含。

An example of this clearly is in HTMLHEAD.ISML. This global include file initializes a host of variables and includes a wide range of support files. Some of these support files are JavaScript based and designed to support UI functionality – such as drop down menus. So based on the above direction, a second file HTMLHEAD_UI.ISML would be created. All of the UI includes, variable initializations, etc. are removed and a single line to Include HTMLHEAD_UI.ISML is added. A blank HTMLHEAD_UI.ISML is created in Core and in the Rich UI cartridge a matching HTMLHEAD_UI.ISML. In the Rich UI version of the file, all of the removed elements from HTMLHEAD.ISML would be inserted.

在文件HTMLHEAD.ISML中就是个很好的例子。全局包含文件初始化一个服务器的变量。然后包含许多支持文件。一些支持文件是基于JavaScript,支持UI功能,例如drop down菜单,基于以上说明,一个HTMLHEAD_UI.SIML会被创建,所以UI引入,变量初始化,等等会被删除。用单独一行的引入HTMLHEAD_UI.ISML。一个空白的HTMLHEAD_UI.ISML在核心被创建,而且在Rich UI cartridge匹配到HTMLHEAD_UI.ISML. 在Rich UI 版本的文件,所有元素从HTMLHEAD.ISML中删除的会被插入。

 

Product Detail Page 产品详情页

Pipeline: Product-Show

Templates:  rendered by product.isml, decorated by pt_productdetails.isml.

 

Product Page Templates  产品页面模板

1. product.isml includes the decorator pt_productdetails.isml which renders all product pages.

2. productdetail.isml decides if it's either a Product Set, Product Bundle or a regular product.

3. productcontent.isml :inventory, pricing, availability and option products, it will be displayed using the respective(分别) included files  inside in productcontent.isml 

such as: 

productcontent.isml  - 推荐内容

productbreadcrumbs.isml  -  导航面包削

modules.isml  - 自定义标签定义

reviews.isml - 评论

productnav.isml - 装饰用

 

Bundled Product Page

rendered with : product.isml

includes : producttopcontent.isml

 

Product Sets

rendered with : product.isml

includes : producttopcontentPS.isml

 

Data Manipulation in Product Detail Page 在商品详情页的数据操作

The data for product.isml comes from several places (all from pdict)

 

a)The Product which identifies the selected product for pricing, recommendations, etc

   定义选中商品的价格,推荐,等等

 

b)ProductSearchResult and ProductPagingModel for rendering productnav.isml and productbreadcrumbs.isml

ProductSearchResult 和  ProductPagingModel 渲染 productnav.isml 和 productbreadcrumbs.isml

   搜索结果,分页 的渲染

 

c)CurrentHttpParameterMap.source to determine if quickview, viewed from cart, or ajax search  CurrentHttpParameterMap.source 

决定是否是快速预览,从购物车预览,或者ajax搜索

 

d)CurrentVariationModel to build the variation swatches

CurrentVariationModel 用于创建变化色板

 

Shopping Cart & Checkout Processing 

six pipelines:

Cart

COCustomer

COShipping

COBilling

COPlaceOrder

COSummary

 

Checkout Programming Concepts 

1.Process:

When a user adds an item to their shopping cart we create a Basket object. Later, when the user wishes to finalize their order, we convert this Basket object into an Order object.

2.group by shipments:

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.

3. LineItemCtr 

All of these objects inherit from the class LineItemCtr (line item container).

 

LineItem Class 

used to: 

1. represent any type of item to be included in the calculation of totals

 

2. 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. 

 

3. 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.

一个Line Item 包含需要购买的商品,使用的优惠券,运费。

 

4. Another type of line item is a PriceAdjustment. PriceAdjustments are used to adjust the price of a particular line item  (like a discount or a surcharge.) They can be a positive or negative adjustment (amount.)

另外一类 line item 是PriceAdjustment, PriceAdjustments用于调整部分line item的单价,(例如折扣和附加费用),他们可以是正数也可以是负数的调整

 

5. OrderPaymentInstruments  are objects that live at a similar level to the line item, but they are not line items, because they are not items to be charged to the user (and calculated in the total,) but rather payment from the user against the total. OrderPaymentInstruments also contain a PaymentTransaction object, which specifies the amount to be charged to the payment instrument. It is not dependent on any number or specific line item(s).

OrderPaymentInstruments 是类似于line item级别的对象,但是他们不是line items. 因为他们并不是需要向客户要价(计算到总计中)。但是是用户对于总计的支付。

OrderPaymentInstruments 还包含支付事务对象,指明需要支付的总金额,它不依赖于任何指定数量的line items.

 

 

6.PaymentInstrument represents a personal method of payment. So it does not only represent a Visa Card, it represents John Smith’s Visa Card. This item points to a payment method (for example a type of credit card) but also contains personal information such as a card holder name, card number and card expiry date.

PaymentInstrument 表示个人支付方式,它并不止表现VISA卡,它表示John Smith的信用卡。这个Item指明了支付方式(卡类型),也包含个人信息,例如持有人名字,卡号,过期时间。

 

Steps for Rendering a Checkout Page  渲染结账页面的步骤

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

从session和数据库获取最新的购物车数据

 

2.Initialize the forms, pre-filling them with the data retrieved in step 1. This is achieved by using the pipelet UpdateFormWithObject. You may specify which dictionary object should be updated with which form group. The individual attributes are updated via mappings defined in the form metadata (bindings.) Later when a user submits data via the forms and having rendered the template, we will leverage the same mechanism with the pipelet UpdateObjectWithForm to store the submitted data in the database

  初始化表单,从第一步得到的数据,预填充表单数据。使用pipelet:UpdateFormWithObject

  通过用户提交,我们利用pipelet UpdateObjectWithForm来存储表单提交的数据到数据库

  

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.

准备视图。检索其他所有的数据,从系统,你需要应用到这个页面的数据。例如shipping方法和支付方法的计算公式,另外一些例子可以是检索购物车或者指定商品推荐,或者促销信息。这个步骤不在pipeline中执行,它可以再isml中执行。或者ajax调用,ajax调用比较推荐。

 

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.

利用ICN节点是很推荐的,它可以自动验证表单,form动作的概念,让你创建非常自定义华的页面流程,页面不用许多公共嵌入点。

 

For this please put a breakpoint on the following Start nodes :

Cart - AddItem

Cart - Show

Cart - COStart

COCustomer - Start

COShipping - Start

COBilling - Start

COPlaceOrder - Start

COSummary - Start

COSummary - ShowConfirmation

 

Shopping Cart

two displays of shopping cart :

1. a mini-cart popup

2.  full-page cart 

puts product to basket: ajax call - invokes the Cart sub-pipeline that is located in the Cart pipeline

 

AddItem Sub-Pipeline

1.allow: adds a product to the mini cart

2.pipelet : AddProductToBasket 

a. creates a ProductLineItem (product sku and quantity) in the basket 

b. returns this object in the pipeline dictionary

 

The overall functionality of the AddItem sub-pipeline:

1. Checks whether product is coming from a product list (wish list or gift registry) - if not it makes sure there is a ProductID

检查是否商品来自wish list 或者 gift registry – 如果不是。确保有一个productID.

 

2. Product object is retrieved

可以取得product对象

 

3. Checks for a basket object. If one is not present, it is instantiated.

检测baseket对象。如果不存在就初始化一个。

 

4. AddProductToBasket pipelet is called – adds a product to the basket

调用AddProductToBasket pipelet, 增加一个商品到baseket.

 

It is important to note that the pipelet creates and returns a ProductLineItem, or multiple line items, by creating these object(s) in the basket, representing the desired product sku(s) and quantity.

Pipelet创建和返回一个ProductLineItem, 或者多个line items. 通过创建这些对象到购物车,表现希望购买的商品的sku和数量

 

5. Once anything is changed in the basket, a cart calculation is always performed. Updates order totals to represent what buyer has done so far.

任何操作在购物车内改变,一个cart计算会被执行。更新订单总计。

 

6. Once the ‘Checkout’ button is pressed, the ‘Cart-COStart’ pipeline is called.

checkout按钮被选,’Cart-COStart’ pinpeline被调用。

 

Cart-Show Sub-Pipeline

the full view page

1.ensure we have created all our form objects in the pipeline dictionary by using the ClearFormElement pipelet to create our form object defined in our form meta-data under the CurrentForms key.

2. we will fill this form with the current data from our basket object.

3. the pipeline Cart-PrepareView first updates the form objects with the basket data,and then it retrieves any page specific data we still require.

4. 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. 

5. The page is rendered using an ICN with many continue actions.

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:

所有这些动作要么是继续购物流程,要么是执行业务操作返回用户到购物车页面。这里有行为的简短描述;

deleteProduct: 

Executes RemoveProductLineItem pipelet for the line item, removing it from the cart.

执行RemoveProductLineItem pipelet 对line item , 从购物车删除。

 

editLineItem: 

Opens a dialog for the user to edit details (typically select a different variant) and replace the line item.

打开对话框给用户编辑细节(选不同花样) , 替换掉line item

 

deleteGiftCertificate: 

Executes RemoveGiftCertificateLineItem pipelet for the line item, removing it from the cart.

执行RemoveGiftCertificateLineItem pipelet 对line item, 把它从购物车删除

 

addCoupon: 

Executes AddCouponToBasket2 pipelet for the input entered into the text field.

执行AddCouponToBasket2 pipelet,输入优惠券号的字段

 

updateCart: 

Typically used in combination with editable quantity fields, this first checks for zero quantities (removing them) and then updates the basket with the shipments form object.

通常使用组合克编辑数量字段,检查0(删除操作),然后更新购物车的shipments信息

 

continueShopping: 

Jumps to Cart-ContinueShopping which checks for the last visited in the click stream redirecting the user to this page.

跳到Cart-ContinueShopping , 检查最新浏览,把用户跳转到那个页面。

 

checkoutCart: 

Calls Cart-COStart which prompts the user to decide what type of checkout they would like to make (guest or registered).

调用Cart-COStart ,让用户决定结账类型,(来宾或者已注册)

 

unregistered: 

Jumps directly to the shipping page, the user has indicated they would like to check out as a guest.

直接跳转到shipping页面,用户表示他们希望结账(作为一个来宾)

 

register: 

Takes the user through the registration process, logging them in and returning them to the cart page.

带用户去注册流程,登录他们,然会到购物车页面

 

login: 

The user is logged in and taken to the shipping page

用户已经登录了,带他们去shipping页面

 

Cart-COStart Sub-Pipeline

use for :  starts the checkout process. 开始结账流程

validates: 

1.  that the basket total could be calculated (not N/A,) that the products represented by the line items are still available on the site 

检查购物车总计是否能被计算,商品是否在售

2. any coupons added to the basket are valid

优惠券是否可用

If successful, the pipeline jumps to the COCustomer pipeline’s Start node.

成功后跳到COCustomer pipeline的开始节点

 

COCustomer Pipeline (first step of the checkout process)

use for : 

provide an option to the visitor to choose checkout type (returning, guest or create account)

提供选项给用户,选择结账类型(返回,游客,或者创建账号)

assume:

visitor selects to proceed with an‘unregistered user’ checkout process.

假设用户选择了未注册用户来结账

Next:

the 'COShipping-Start' pipeline/Start node is called

调用 'COShipping-Start' pipeline/开始 节点

 

COShipping Pipeline (配送pipeline)

use for :

is the starting point for single shipping scenario. (每一种配送的开始)

ICN: 

that asks for visitor input of where they want their items to be delivered.

询问方可输入他们希望的配送信息

ajax call:

Once a shipping address is entered successfully, the UI makes an ajax call to the public pipeline COShipping-UpdateShippingMethodList, which calculates the applicable shipping methods for this basket.

一旦配送信息填写正确,UI会做一个ajax调用公用Pipeline,

COShipping-UpdateShippingMethodList - 计算可对购物车可以使用的shipping方法

Shipping Method Module:

In BM, in the Shipping Methods module, rules and costs can be defined for each shipping method which will be considered while calculating this list of methods and costs. 

The interface (view) is then updated with the applicable shipping methods and costs.

check no empty shipments

jump node to the ‘COBilling-Start’ pipeline/Start node.

 

COBilling Pipeline

use for:

starting point for billing . implements the billing logic.

responsible for: 

providing the payment method selection as well as entering a billing address. 

If the visitor had selected in the shipping form to use the same address for billing:

如果用户选择了和shipping一样的信息。

then the address will be pre-populated from relevant fields.

地址会被shipping的信息来填充

 

Payment Methods Module

1.Payment methods can be defined in the Payment Methods module of Business Manager. T 

支付方法模块 BM中有配置模块。

 

2.As part of step 3 (prepare the view) for the billing page, we will retrieve a list of applicable payment methods and cards. 

在上一步的billing 页面我们会获得可用支付方式和卡

 

3.When the user submits payment information, 

当用户提交支付信息

that payment information is validated against any rules defined in business manager for that payment method/card.

支付信息会被针对任何规则定义来验证。(支付方式、卡类型)

 

4. If the payment information is valid, a payment instrument is created based on the data submitted in the form. 

如果支付信息合理,一个payment instrument被创建,

 

5.There can be multiple payment instruments since an order can be paid partially with a credit card and partially with a gift card, certificate or even multiple credit cards.

可以有多个payment instruments 因为订单可以被分开支付,一部分用信用卡。一部分用礼品卡,或者多张信用卡

 

6. Once the payment method is successfully created, the pipeline exits with a jump node to COSummary

一旦支付信息成功创建,pipeline跳转到COSummary

 

COSummary Pipeline 

template:  summary.isml

display: totals, shipping, billing and payment panels at the right side of the checkout page. 

action : Once the ‘Submit’ button is clicked by the visitor, the ‘PlaceOrder’ action for the button calls the COPlaceOrder pipeline.

 

COPlaceOrder Pipeline

responsible to : create an order from the current basket.

1. Gets the existing basket 获取已存在basket

2. Makes sure the shipments are in order 确保配送信息

3. Calculates the cart 计算cart

4. Validates the payment 验证支付

5. Checks inventory of product line item 检查商品库存

6. Checks coupons to make sure they are still valid 检查优惠券可用性

7. After these final checks are complete, inventory for the order is reserved using the CreateOrder2 pipelet and a database transaction is opened.

CreateOrder2 pipelet :

creates an Order based on the specified Basket

return : 

CREATED 

The Basket will be removed from the session and marked for removal.

8.  creating an order number and processing the payment.

The processing of the payment method ends with either:支付处理的结果 如下

a. Authorize , the 'PlaceOrder'  sub-pipeline is called.

b. End

c. Decline

d. Error

9. PlaceOrder sub-pipeline:

responsible for:  creating the order , setting the order confirmation status.

PlaceOrder Pipelet: 

a. decrements inventory for all products contained in the order.

b. redeems all coupons contained in the order.

10. order is placed and the database transaction has successfully been committed

a. a confirmation email is sent to the buyer. 

b. The pipeline will then exit with a jump node to COSummary-ShowConfirmation

COSummary-ShowConfirmation : 

displays a confirmation ICN node to the buyer that gives the buyer the option of creating an account. 

11. If the order creation has failed

the pipeline exits with a jump node back to the order summary page.

 

Site Maintenance

Page download time: a critical factor in keeping visitors in your storefront

category ,  search result pages , product detail pages should use cache

 

<iscache>

syntax:

<iscache type="relative" hour="24">

 

These are the rules when using the tag:

 

1. If <iscache> tag occurs multiple times in a template or its locally included templates, the shortest duration is used

如果<iscache> 标签发生多次。在一个template或者它的本地引入模板,会取最短周期的使用。

 

2. Caching from a local include affects the including template

Caching来自本地引入会影响到被引入模板

 

3. If there is no <iscache> defined, the template is not cached

如果没有<iscache>标签定义,模板就不会被缓存

 

 

Caching Parameters

1. status = "off|on"

a. off disables page caching

b. on enables page caching (the default) 

 

This setting allows for caching to be turned on and off programmatically. 

status="off" is considered the shortest duration, so be careful when using it on an included template (see rules above).

 

2. type = "relative | daily"

a. Relative:  allows you to specify a certain period of time(一段时间), in minutes and hours, after which the page will be deleted from the cache. 

b. daily: allows you to specify a specific time when the page will be deleted from the cache.

 

3. hour = integer

type = "daily" : the hour value must be an integer ranging from 0 to 23

type = "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.

 

4. minute = integer

type = "daily" : the minute value must be an integer ranging from 0 to 59.

type = "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

 

5. 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 only be marked with the varyby property if the page is really personalized; otherwise, the performance can unnecessarily degrade.

 

Frequently changing pages benefit 有利于 from a shorter caching period. Stored pages are only invalidated and a new one pulled from the Application Server if:

从减短缓存周期对频繁的更改页面有好处。存储页面只是单独的而且一个新的从应用服务器获取

1. The defined caching time is exceeded, or

定义cache时间为溢出的

 

2. A replication has been performed (with the exception of coupons and geolocation data), or

一个复制已经被执行(除了coupons 和地理信息)

 

3. An explicit page cache invalidation is triggered by a merchant in BM

明确的页面缓存删除被商家从后台触发

 

部分页面缓存

Portions of pages(部分页面) can be cached separately(分开). You can assemble a page from snippets(片段) with different caching attributes using remote includes. Each part:

a. Has to be a result of a pipeline request to the application server

必须是一个pipeline请求的结果

b. Is included using the syntax: 远程包含语法

<isinclude url=""> or the <iscomponent pipeline=….> 

c. Can have different cache times or no caching at all 

可以有不同的cache时间,或者不使用缓存

d. do not cache pages that show buyer or session information.

不缓存买家和session的信息

 

Page Analytics:页面分析 (有助于决定缓存的问题)

caching metrics under : Site  ⇒ Analytics  ⇒ Technical Reports 

callected on : only on Production instances

two critical metrics: 

1. Search-Show

the average response is 400ms. Customers should be <= to this value to be in a good performance range.

2. Product-Show

the average response is 320ms-400ms. Customers should be <=to this value to be in a good performance range.

   when to check analytics reports?

1. each week 

2. after you make code changes to track these metrics.

 

Cacheing Type:

1. Page Level Caching

use tag : <iscache> tag

use for :  the entire ISML page will be cached for the time specified in the tag.

example: 

the page below will be cached for 1 hour and 30 minutes:

<iscache type="relative" hour="1" minute="30" >

2. Partial Page Caching

remote inculdes : Every remote include calls a different pipeline which generates an ISML template, each template having (possibly) different page caching.

每次远程引入一个不同的pipeline,(会生成ISML模板)每一个模板有(可能)不同的page缓存信息

syntax: 

a. <isinclude>

<isinclude url="${URLUtils.url('Page-Include', 'cid', 'COOKIE_TEST')}">You can also use the newer <iscomponent> tag to implement a remote include.

b. <iscomponent>

<iscomponent pipeline="Product-IncludeLastVisited" />

 

Storefront Toolkit:

Cache Information tool 

 

Site Performance 网站性能

The Pipeline Profiler (Pipeline分析器) is a tool in BM that gives you insight into pipeline and script performance.

located :  Administration > Operations > Pipeline Profiler.

 

Code Replication 代码复制

Overview: 

1. When a developer has tagged a new code version and is ready to upload the new code to staging, he/she creates a new code version on STAGING in BM :

Administration > Site Development > Code Deployment

当一个开发人员标记一个新的代码版本,准备上传代码到staging, 他创建一个新版本到staging上

 

2. the developer uploads custom cartridges with Studio or WebDAV client using 2-factor authentication and tests the storefront in STAGING. A rollback to a previous version is available.

当开发人员上传自定义的cartridge用Studio或者WebDAV, 使用2-factor身份验证,然后测试前台在STAGINGA上面。这时候有一个可以回滚到上个版本的机会。

 

3. For major code changes, it is recommended to use a sandbox for testing

主要代码修改,推荐使用sandbox来测试

 

4. 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.

为了在sandbox上测试,你将导出site数据出全局目录。从staging,然后倒入到你的sandbox。

 

5. 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:

当代码meta data(site表现,新属性,等等)需要被测试。一个staging复制到development会被执行

 

6. This is also good practice for testing processes without impacting the production storefront (i.e. Product import feed).

这样不会影响到正式环境(比如说商品导入)

 

7. The last step in code replication is moving code from STAGING to PRODUCTION.This process is also performed in Business Manager.

最后一步是代码复制移动,从STAGING到PRODUCTTION, 也是在BM中执行

 

Data Replication 数据复制

哪里使用?:

promote merchant edits, product and system objects from Staging to Production (or Development)

促销规则修改,商品,系统属性。从staging到production(或者Development)

 

Best Practices:

1. replicate to development first, verify that data and storefront work 

2. replicate from staging to production.

 

Data can be replicated granularly: 数据可以被选择性复制

1. Organization objects

2. Per Site objects

 

A Data Replication process consists of two phases:

1. Transfer 

long running processes where data is copied from STAGING into“shadow” tables and folders on PRODUCTION. No changes are shown in storefront.

2. Publishing 

Very fast process. Changes in “shadow” tables and folders become active, page cache is cleaned, and the new version is shown in storefront.

 

After data has been replicated

1. a one-time rollback (undo) is possible.(the last successful replication)

 

The process is almost identical with the exception of being able to select which data you want to replicate.

与代码导入不同的是可以选择性复制

 

one-way from STAGING 

Just as code replication can only occur between STAGING and DEVELOPMENT or STAGING and PRODUCTION, so too is the data replication process only allowed one-way from STAGING to the other primary instances.

和代码复制一样,只能发生在STAGING和DEVELOPMENT或者STAGING和PRODUCTION之间,数据复制也是一样。只允许从STAGING出发单向的复制到其他的主要实例

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/224582
推荐阅读
相关标签
  

闽ICP备14008679号