Cartridges
What is a Cartridge?
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.
The storefront.properties file is generated by Studio when a new cartridge is created. This file is required.
Cartridge Path
In order for a site to use a cartridge, the cartridge must be added to the cartridge path in Business Manager.
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.
Add Cartridge in Cartridge Path
1. Administration -> Sites -> Manage Sites -> {Select Site} -> Settings tab
2. Add Cartridge Path:
Cartridges can be added to the cartridge path by typing a colon (:) between cartridge names. All names here are case sensitive and must match the names of your cartridges in eclipse. There should be no spaces in-between each item.
e.g. training:storefront_richUI:storefront
Cartridge Types
There are three types of cartridges you can create in UX Studio:
1. Storefront cartridge
2. Demandware cartridge
3. Business Manager cartridge (本课不介绍)
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:
Generic: reusable code used in multiple sites
An integration to an external system
Specific to a localized site: css, images and resource files for a language-specific site.
1) Keep an original SiteGenesis cartridge in your project just for comparison purposes, but don't make it part of the cartridge path
2) Use another storefront cartridge for common code that you intend to
reuse in multiple sites: <client>_core
3) Create cartridges for site-specific functionality that might overwrite the core: app_<site>
4) Any integration code should go in a int_<site> cartridge
View WebDAV cartridge directory in Business Manager
1. Administration -> Site Development -> Development Setup
2. In the WebDAV Access section, click the link for Cartridges.
Create a new version on the server
1. Administration -> Site Development-> Code Deployment.
2. Click Add to create version2. Click Apply.
3. In Studio, open the Demandware-> Change Upload Staging Directory…
Creating a New Cartridge
When you need to segregate (分离) code between sites, you may want to create a new empty cartridge. Creating a new empty cartridge will enable you to add only the code you need for a site or specific sites in an organization.
Create a new empty cartridge
1. File -> New -> Demandware Cartridge.
Creating a Storefront Cartridge
When you create a new storefront cartridge in UX Studio, a copy of the
sitegenesis_storefront_richUI and sitegenesis_storefront_core cartridges will be downloaded to your workspace and renamed with the name you specify. As mentioned before, these reference cartridges have all of the code needed for a SiteGenesis storefront to work in the Demandware platform. As part of the architecture approach since the 12.6 deployment, Demandware will be separating the Site Genesis cartridge into two distinct cartridges based on the following functional guidelines:
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 SiteGenesis storefront as we know it today. That being said, it is important to know that the 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.
When you make changes to the new storefront cartridge, your changes will be uploaded to the Demandware server and can be viewed immediately as long as you:
1) Set the cartridge to be uploadedto your workspace server
2) Put the new cartridge in the cartridge path
l Have site caching disabled for the site
Create a New Storefront Cartridge
1.UX Studio: File -> New -> Demandware Storefront Cartridge