B2C App Development (53%)

¡Supera tus tareas y exámenes ahora con Quizwiz!

What file extension can a controller have?

*.js or *.ds

What file extensions can a module have?

*.js, *.ds. *.json

What can you use to maintain state?

- Client-side Cookies (storied in the browser) - The user's session (stored on the app servers) - Persistent Business Objects (i.e. the database)

What can a cartridge contain?

- Controllers - Templates - Scripts - Form definitions - Static content (images, CSS files, and client-side JavaScript files) - WSDL files

Give an example of setting a page's TTL in the cache.

//For 1 day response.setExpires(new Date().getTime() +24 * 60 *60 *1000 ); Note this is: Hours * Minutes * Seconds * Milliseconds

What are the options for caching at the application layer (eComm)?

- Request Caching - Custom Objects - Custom Caches - File Caches - Session Cache

What is a "Set of String" data type?

- Similar to a Salesforce Pick List. - It's an array of strings. - Cannot contain duplicates. - Use when you want the merchant to enter one or more strings. There are also sets of Integers and Numbers that work the same way.

What are common issues with trying to download a cartridge?

- The server connection was disabled. - The server did not access your cartridge.

Where is caching supported in B2C Commerce Stack?

- eCDN -> Static Content Caching (images, CSS, Client-side JS) - Web Server Layer -> Page Cache - Application Server Layer -> Custom Caches (CacheMgr) - Storage Layer -> Custom Attributes or Custom Objects

How do you create a page partition cache?

1. Administration -> Sites -> Manage Sites -> site -> Cache 2. Click the Cache Tab 3. Add Partition 4. Configure the partition. 5. Add the Pipelines to the partition.

What are File Caches good for?

1. File caches are great for build-time optimizations, for example, if templates need to be generated (in scenarios where template languages other than ISML are used). 2. They are also useful where development code can be optimized or environment-specific configurations need to be created.

What can controllers use require for?

1. Import script modules. Any B2C Commerce script can be made into a CommonJS module and required by a controller. 2. Import B2C Commerce packages, instead of using the importPackages method. This approach is the recommended way to reference functionality from a controller. 3. You can also use the require method to import a single B2C Commerce class. var rootFolder = require('dw/content/ContentMgr').getSiteLibrary().root;

How can page caching be implemented?

1. In JavaScript: dw.system.Response#setExpires(milliseconds). 2. In a template: <ISCACHE> tag In the SFRA, there are decorators that wrap setExpires. The decorators apply preconfigured caching times. Setting the caching policy in a JavaScript controller with the setExpires method is recommend over the <ISCACHE> tag. Both approached control caching an entire page, not just a template.

How big can log files get?

10 MB a day.

Do script modules have to be in cartridges?

No. Script modules are CommonJS modules. They can be in cartridges, but they don't have to be. Public objects and methods are exposed using the exports free variable.

Can all methods on a controller handle storefront requests?

No. Exported methods for controllers must be explicitly made public to be available to handle storefront requests.

How can we use the CSS style selector '#' in templates?

The # character is reserved in isml templates. To use it in a tag or nested JavaScript got to process it. Example Replace <a href="#">Link</a> With: <a href="${'#'}">Link</a>

How can the below be rewritten to mitigate XSS attacks? <span class="term"> "${!empty(pdict.ProductSearchResult.searchPhrase)?pdict.ProductSearchResult.searchPhrase:''}" </span>

<span class="term">" <isif condition="${!empty(pdict.ProductSearchResult.searchPhrase)}"> <isprint value="${pdict.ProductSearchResult.searchPhrase}"/> </isif> </span>

What is a cartridge?

A cartridge is a mechanism for packaging and deploying program code and data. Use cartridges to extend business functionality or integrate with external systems. A cartridge can deliver generic or application-specific functionality.

What is a page cache partition?

A page cache partition is the page cache for a group of pipelines. It enables invalidating them all at once. - A pipeline can only be in one partition. - You can create a maximum of 10 partitions. - Each partition can contain up to 10 pipelines. - Purging a cache invalidates the cache entries over 15 minutes.

What is the Commerce Cloud Developer Center?

A public portal for developers who are building commerce applications. The Developer Center provides extensive resources for B2C Commerce developers, including reference materials for the Salesforce Commerce API, access to a sample app and developer tools, links to learning resources, and a community forum. - Explore the Salesforce Commerce API and other developer tools. - Use the mocking service to try out the APIs. - Build a sample app. - Reference Solution Kits that describe common use cases. - Find links to Trailhead and other resources to learn about developing for B2C Commerce. - Post questions and participate in discussions with other developers in a forum monitored by B2C Commerce product experts.

How can dynamic and static content be mixed while still leveraging caching?

A remote include is a server-side content hosted on a static page. The static content is hosted on the web service layer in the page cache. The web tier will insert the dynamically computed piece of the page into the cached frame and the result is a complete page that has both cached and uncached elements on it.

What is the WebDAV?

WebDAV (Web Distributed Authoring and Versioning) is an extension of HTTP that allows clients to perform remote Web content authoring operations. The WebDAV1 protocol provides a framework for users to create, change and move documents on a server.

How do you register a cartridge?

After creating a cartridge, upload it to a server and register it to a site. You can register a cartridge to multiple sites. 1. Select Administration > Sites > Manage Sites > site. 2. On the Settings tab, enter one or more cartridge names in Cartridges, separated by colons. Cartridges take precedence in order from left to right. 3. Click Apply

What is the difference between client-side scripting and B2C Commerce JavaScript

B2C Commerce JavaScript is executed on the server side in the Rhino JS engine. Client side is executed in the browser.

What is the default error code for unavailable resources?

By default, B2C Commerce returns a 410 error, which indicates that the resource is no longer available. If you prefer 404, it's fine to use as long as the related ISML template doesn't include <isslot>, <iscomponent>, or <isinclude> tags. When you want to handle these errors explicitly, you can use try/catch statements.

What are the B2C development components?

Cartridges, Controllers, Scripts, Templates, Forms.

How can you change the global timeout settings?

Contact SF Support. The global settings are at: Administration -> Global Preferences -> Global Timeouts

What is a controller?

Controllers are server-side scripts that handle storefront requests. Controllers manage the flow of data in your application, and create ViewModels to process each storefront request as a route and generate an appropriate response. For example, in a storefront application, clicking a category menu item or entering a search term triggers a controller that renders a page.

Where do controllers live in a cartridge?

Controllers must be located in the controllers folder at the top level of the cartridge.

Where are the Java related errors logged?

error_* log files. These are primarily used by SF staff.

How can you prevent manipulating content (XSS) in templates?

Ensure that all shown content is encoded. Automatically encode all output in a template to HTML with: <iscontent type="text/html" charset="UTF-8" compact="true> To encode a specific value use: <isprint value="${...}">

When debugging, how can you find a template's name

For static templates: Check the interaction node properties. The Interaction Template Name property shows the name of the template called by the interaction node. For dynamic templates: The name can be determined dynamically at runtime using the Pipeline Dictionary. For example, if products and categories are visible, the storefront is using a dynamic template. This is indicated by a D in the symbol of an interaction node. In side of Business Manager, the Storefront Toolkit can be used to identify which parts of a page belong to which templates.

What are ISML tags?

ISML tags are extensions of the tag-based language conforming to SGML standards. - All tags start with "is". - Tag names and attributes are NOT case sensitive. - Attribute values ARE case sensitive. Lowercase is the SF best practice. There are only 31 ISML tags.

When should the session cache be used?

If you need to cache smaller pieces of information for a given user, the session might be your best option. It is easy to implement and the data can be used for building dynamic customer groups. Use: session.custom for building dynamic customer groups. Use: session.privacy to not build dynamic customer groups. This does not trigger customer group update and is cleared after logout.

What does <isinclude> do?

Import content from another template file (local include) or execute a 2nd pipeline that returns information (remote include). Example <isinclude template="reporting/reportingUrls" />

How can you download a cartridge from an instance?

In Business Manager 1. Administration > Site Development > Code Deployment 2. Click the code version you want to download. 3. On the Version Summary Page, click download.

How do you configure a static content cache?

In Business Manager: 1. Administration -> Sites -> Manage Sites To configure the global cache for shared static content, click Global Static Cache. To configure the static cache for a site (including the Business Manager site), click the site, then click the Cache tab.

How can you see the WebDAV available URLs?

In Business manager: Administration > Site Development > Development Setup

How can you cache a small piece of data on the app tier (eComm)?

In a controller, use a custom attribute via request.custom property.

What is the difference between the Integer and Number data types?

Integers are integers in the typical sense. Numbers are floats.

What does <isdecorate> do?

It decorates the enclosed content with the contents of the specified decorator template. Example <isdecorate template="common/layout/page"> ... Inner template content </isdecorate>

What does <iscontent> do?

It specifies the content type (e.g. text/html) of a rendered template. Example: <iscontent type="text/html" charset="UTF-8" compact="true>

How can a custom object be used as a cache?

It's not really a cache... Custom objects are stored in the database. They can be imported and exported, they can be both written and read, and they are persisted and thus consistent across all application servers. Typical use cases here include scenarios where the cached data must not get lost. A common use case is to act as intermediate storage for data that will be processed later.

What languages can you write controllers in?

JavaScript and Salesforce B2C Commerce Script. They must conform to the CommonJS module standard.

ISML Utility Functions

Javascript functions to help with common tasks. They can all be invoked in the scope of a template. - dw.system.Request - dw.system.Session - dw.util.StringUtils - dw.web.URLUtils

What are the Enum of String and Enum of Integer data types for?

Multi-select pick lists.

When should you require a module in your code?

Only require modules when you need them, not at the top of a module.

How do you configure the page cache?

Page caching is configured by site. 1. Administration -> Sites -> Manage Sites 2. Click the desired site (including the Business Manager site), then click the Cache tab.

What is personalized caching?

Personalized caching is specific to a single user. This is accomplished by dynamically adding the currently active price books and applicable promotions to the cache key (url w/ query string). This approach increases the number of cache entries per page. 2 people on the same page, but different price books results in two cached URLs.

What is request caching?

Request caching enables saving data for a single request in a module. It is on the application tier (eComm). For example: You need to save a customer's selected store. but don't want developers to directly interact with it. The module can save the store ID internally and only expose methods to return the store object itself.

How doe the CacheMgr work?

The CacheMgr JavaScript class is responsible for managing custom caches on the app tier (eComm). The CacheMgr can manage multiple custom caches that share one storage space. Each individual cache has a unique ID and an optional expiration time that specifies the maximum time (in seconds) an entry is stored in the cache. For registering caches inside the cartridge root folder, a 'package.json' file with a 'caches' entry must exist. The registration of caches is independent of any site context.

What does a template do?

Templates either deliver input data or show a pipeline's output data on the browser.

Where do templates live?

Templates must be located in a locale-specific folder in a cartridge. /cartridge/templates/ With /cartridge/templates/default being the default locale.

What are the default TTL caching values for both static content and pages?

Static content is cached by the web server (JWA). - The default is 30 days (2,592,000 seconds). - For production instances, the minimum TTL is 24 hours (86,400 seconds). - To disable caching of static files, enter 0. - Setting the TTL affects both the static content and page caches.

What is the difference between a String an a Text data type?

Strings are for letters, numbers, and punctuation. Use for a word or sentence. Max of 4k bytes. Text is for large amounts of text, such as descriptions. Strings are queryable in Business Manager, text is not.

How are templates triggered?

Templates are always triggered by a pipeline.

What does the Error.js controller do?

The Error.js controller services uncaught errors.

How can you view the available key-value pairs available in the Pipeline Dictionary?

The Properties editor of a pipelet shows all of the available key-value pairs in UX Studio.

What is the Script Debugger API

The Script Debugger API is a JSON-based set of requests and responses that are managed using a REST servlet. This RESTful API enables you to create applications that interact with the Script Debugger for setting breakpoints, viewing variables, and evaluating expressions. This API is NOT available on production instances.

How long can scripts run before timing out?

The Script pipeline node has a Timeout input parameter that controls how long a script can run. The default is 30 seconds for storefront requests and 15 minutes for running jobs. Max is 5 minutes for storefront requests. 60 minutes for job pipelines. All storefront requests have an extended timeout of 5 minutes when a debugger session is running. Scripts in templates have an automatic timeout of 5 minutes.

How long can a script stay on a breakpoint?

The max debugging timeout is 30 minutes.

How can you purge the page cache for remote includes and iscomponent elements?

The page cache for remote includes and iscomponent elements are not automatically invalidated when the page cache for the pipeline that contains the rendering template is invalidated. If you want to refresh the content on the Home page by invalidating the Home-Show pipeline and you have remote includes to Content-Show, then you must also explicitly invalidate the Content-Show pipeline.

What is the page cache?

The page cache is a key-value store at the web server layer. The key is the full URL (including query string). The value is the cached page.

What is a custom cache?

They are NOT shared across application servers. They are best used to save intermediate results of expensive operations or operations that happen very frequently. dw.system.CacheMgr class is the entry point for using custom caches.

Where are B2C Commerce JavaScript files stored?

They must be stored in the /cartridge/scripts folder of a cartridge with the *.ds extension.

How are B2C Commerce Script modules loaded?

They're just CommonJS modules so they're loaded using the JavaScript TopLevel.global.require(path) method. Example var m1 = require('./mod1.js'); Paths that start with "dw/" are built-in modules.

How can irrelevant query parameters be excluded from the page cache?

This can be done at a global level, not a page level. In Business Manager Administration -> Global Preferences -> Feature Switches 1. Enable the feature: Web Adapter Cache Key Ignore by Query String 2. Provide a comma separated list of the query string keys to be ignored.

How can OCAPI caching be configured?

This can be done declaratively in Business Manager by submitting a JSON document. Administration -> Site Development -> Open Commerce API Settings The cache setting are configured at each API level individually.

What does <ismodule> do?

Used to create a custom tag (e.g. <my-tag>) from a template. Store them as a stand alone template in its own file. Example <ismodule template = template_path \\required name = tag_name \\required attribute = attr_name \\0 or more /> The template_path is the template file that implements the logic of the tag. The <ismodule> is physically separate from the logic template.

How can you view log files?

Using the Request Log View in the Storefront Toolkit on instances other than development and production.

What is the Pipeline Dictionary?

When a controller or pipeline is processed, the Pipeline Dictionary accepts and stores parameters in key-value pairs. A template can only render data that is stored in the Pipeline Dictionary at the time the template is called. Controllers do not manipulate the Pipeline Dictionary directly. Rather, they construct an object that is passed to a template.

Can controllers call other controllers?

Yes, but this is not recommended to avoid circular dependencies.

Can a controller import packages directly?

Yes, however it is discouraged because it doesn't use standard JavaScript patterns. This approach is Rhino-specific.

Can user sessions be shared across multiple brands?

Yes. A single site can have multiple brands. To retain session information, customers click redirect links in the storefront to switch from brand A to brand B. The redirect link keeps the customer in the same site, the same session and their shopping basket is preserved. Note: User sessions and shopping baskets CANNOT be shared across sites. Example <a href="${URLUtils.sessionRedirect('www.a-brand.com',URLUtils.home())}">Brand A</a>

Can a controller call a pipelet?

Yes. However, it is strongly discourage calling pipelets from within a controller. However, it's allowed while there are still pipelets that don't have equivalent B2C Commerce script methods.

How can cartridges be downloaded from a Realm?

You can download or view a deployed cartridge with a web browser or WebDAV client.

How are cartridges activated for a store front?

You configure which cartridges are in use by entering a list of those cartridges in Business Manager . The order in which cartridges are listed matters. The list is basically a class path, with the cartridge as the class. If you want to overwrite files with a particular cartridge, put the cartridge at the end of the list. Use the code upload version directories to change the active directory.

Where are Javascript-related errors logged?

customerror_* log files include almost any JavaScript related errors, including errors from B2C Commerce scripts and controllers.

What is the format for accessing a cartridge via WebDAV

https://<hostname>/on/demandware.servlet/webdav/<organization>/​cartridges/<code version ID> The currently selected code version is stored in this file: https://<hostname>/on/demandware.servlet/webdav/<organization>/​Cartridges/.version


Conjuntos de estudio relacionados

APUSH 9 weeks Multiple Choice😺

View Set

FL P&C Comprehensive Practice Test

View Set

Called to Believe by Steven P. Mueller, Ch 9

View Set

VirtualSC Honors Economics Final Exam

View Set