Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 28 ยท Practice and Review

SFCC Interview Questions

Prepare for a Salesforce B2C Commerce developer interview: concise answers on cartridges, SFRA, hooks, caching, OCAPI and SCAPI, jobs and performance, with two stand-ins.

A Salesforce B2C Commerce interview usually mixes vocabulary questions ("what is a cartridge path?") with judgment questions ("a product page is slow only for logged-in shoppers; where do you start?"). Good answers are short, use the right terms, and show that you know the trade-offs. Interviewers also listen for what you would not do, such as editing the base cartridge or caching a page that contains personal data.

This page groups common questions by topic and links each to the lesson that explains it in depth. The platform cannot run on this site, so real code is read-only, and the two runnable examples at the end are plain JavaScript stand-ins that illustrate the reasoning. They are not the Script API. Say each answer aloud before you read ours, then compare. Platform behavior changes between releases, so where a detail depends on the version, the answer says so.

flowchart TD
    Q["Interview topics"] --> A["Architecture<br/>and cartridges"]
    Q --> B["SFRA<br/>controllers, models, ISML"]
    Q --> C["Extending<br/>hooks and services"]
    Q --> D["APIs and headless<br/>OCAPI, SCAPI, PWA Kit"]
    Q --> E["Jobs, caching<br/>and performance"]

Five areas that cover most B2C Commerce developer interviews.

Architecture and cartridges

What is Salesforce B2C Commerce?

A hosted e-commerce platform where Salesforce runs the infrastructure and you deploy code, configuration and content. You work with a storefront framework (SFRA or a headless PWA Kit storefront), the Script API, Business Manager and a set of APIs. See What Is Salesforce B2C Commerce?.

What are the instances and what is a realm?

A realm groups the instances of one customer. A typical realm has production, staging and development instances (together the primary instance group), plus on-demand sandboxes for individual developers. Code is uploaded as a code version, and one version is active per instance. Data and content move between instances by replication or import/export.

What is a cartridge?

A deployable folder of code and resources: controllers, scripts, ISML templates, static files, forms, client-side source and more. Cartridges are not applications by themselves. The site's cartridge path lists them, and that list decides what runs. See Cartridges and the Cartridge Path.

How does the cartridge path work?

Resources are looked up from left to right and the first match wins. So plugin_x:app_brand:app_storefront_base means a template in plugin_x shadows the same-named template in app_brand, which shadows the base. You customize by putting your cartridge to the left of the base, never by editing the base.

Why not edit app_storefront_base directly?

Your change disappears or conflicts the next time you take a base update. An overlay cartridge to the left of the base keeps your code separate and upgradeable. This is the most common "what would you not do" question.

What are SiteGenesis, SFRA and PWA Kit?

SiteGenesis is the older reference storefront built on pipelines and widely replaced. SFRA (Storefront Reference Architecture) is the server-rendered reference storefront built on controllers, models and ISML. PWA Kit is the headless, React-based storefront that talks to the platform through the Commerce APIs and runs on Managed Runtime. See Headless Storefronts with PWA Kit.

What language does the server code use?

JavaScript, run by the platform's own engine. Syntax support depends on the compatibility mode of the code version, and modules are loaded with require, so check the documentation for what your code version allows before using newer syntax. Server code cannot use npm packages at runtime unless they are bundled into your cartridge.

SFRA: controllers, models and templates

Describe the request flow in SFRA.

A URL such as /Cart-Show maps to the Show route in the Cart controller. The route is a chain of functions (req, res, next): middleware first (for example HTTPS or CSRF checks), then your steps. Steps put data into res.viewData or call res.render or res.json. See SFRA Architecture and Request Flow and Controllers, Routes and Middleware.

append, prepend and replace: what is the difference?

They are server methods for extending an existing route from your own cartridge. prepend adds a step before the route's own steps, append adds one after, and replace swaps the whole route for yours. Prefer append and prepend, because replace carries all future base changes on your shoulders.

JavaScript
// plugin_gift/cartridge/controllers/Cart.js (read-only: needs the real platform)
'use strict';

var server = require('server');
server.extend(module.superModule);

server.append('Show', function (req, res, next) {
    var viewData = res.getViewData();
    viewData.giftWrapAvailable = true;
    res.setViewData(viewData);
    next();
});

module.exports = server.exports();

What is module.superModule?

A reference to the module with the same path found further to the right on the cartridge path. It lets an overlay cartridge extend a base module, controller or helper instead of copying it. The first stand-in below imitates it.

What are models and decorators?

Models turn platform objects (a Product, a Basket) into plain JSON-friendly objects for templates and APIs. A decorator is a small function that adds one group of properties to a model with an enumerable property. Composition of decorators keeps models flexible. See Models, Decorators and Helpers.

How do you prevent XSS in ISML?

<isprint> encodes by default, which is the safe path. Choose the encoding that fits the context and avoid encoding="off" unless the content is trusted markup you control. Never build HTML in controllers from user input. See ISML Templates and Security, Sessions and Compliance.

How does CSRF protection work in forms?

POST routes that change state use the CSRF middleware, and the form includes a token generated by the platform. The server rejects a request whose token is missing or wrong. Details are in Forms, Validation and CSRF. Always validate on the server as well; client checks are only convenience.

Extending the platform

What is a hook?

A named extension point that the platform (or your code) calls through HookMgr. You register implementations in a hooks.json file referenced by the cartridge's package.json. Examples are the basket calculation hook dw.order.calculate and the OCAPI/SCAPI hooks around shop API calls. See Hooks and Extension Mechanisms.

Hook versus overriding a controller: when do you choose which?

Use a hook when the platform already offers an extension point for the process (calculation, API response changes, payment steps). Use append or prepend on a route when you need to change the storefront request flow. Hooks also work for headless storefronts, because they run for API calls, while a controller change affects only the SFRA pages.

How do you call a third-party service?

Through the service framework: define a service in Business Manager (URL, credentials, timeout, circuit-breaker and rate-limit settings), then create it in code with LocalServiceRegistry.createService, supplying createRequest and parseResponse. A mockCall makes tests possible without the network. Never hard-code URLs or secrets in scripts. See Service Framework and Third-Party Integrations.

Where do secrets live?

In the credentials of a service definition, or in password-type attributes, never in source code, site preferences of plain string type or logs.

Custom attribute, custom object or site preference?

A custom attribute extends something that already exists (an order flag). A custom object is a separate small keyed record (an export state). A site preference is a merchant-editable setting. Large or relational data belongs in an external system. See Custom Objects and System Object Extensions.

APIs and headless

OCAPI versus SCAPI?

OCAPI (Open Commerce API) is the older REST API family, with a Shop API for storefront use and a Data API for back-office use, configured per client in Business Manager. SCAPI (Salesforce Commerce API) is the newer family, served through a different gateway, with shopper authentication done by SLAS (Shopper Login and API Security Service). New headless work targets SCAPI. See OCAPI and SCAPI.

How does a shopper get a token in a headless storefront?

The storefront asks SLAS for a token, using a client ID registered for the site. A guest receives a guest token, a registered shopper logs in and receives their own, and the access token is short-lived and renewed with a refresh token. Never put a client secret in browser code; public clients use the PKCE flow.

When would you choose PWA Kit over SFRA?

When the team wants a React front end, app-like behavior and independent front-end releases, and accepts the extra moving parts (Managed Runtime, API-only data access, separate caching). SFRA is the simpler choice for server-rendered storefronts with fewer front-end ambitions. The trade-off is in Headless Storefronts with PWA Kit.

Jobs, caching and performance

What is a job and how do you build a custom step?

A job is a named list of steps run on a schedule or on demand. A custom step is declared in steptypes.json and implemented as a script function that returns a Status. See Jobs, Feeds and Import/Export and the worked order export project.

How do you make a job safe to rerun?

Make every unit of work idempotent: compare before writing, keep the state on the object being processed, use an idempotency key for outgoing calls, and keep transactions short. A rerun after a crash then finishes the job instead of duplicating it. See Idempotency.

How does page caching work?

Responses can carry a cache time (in ISML with <iscache>, in SFRA with caching middleware), and the platform's CDN layer serves cached pages for shoppers without re-running your code. Everything that changes the output must be reflected in the cache entry's identity, and personal content must stay out of shared pages: load it with a remote include that has its own cache rules, or fetch it with a separate request. See Caching and Performance.

A page is slow only for some shoppers. What do you check?

First, whether it is cached for guests but not for signed-in or basket-holding shoppers. Then the request log and the profiling tools for slow scripts, repeated queries inside loops and large result sets. Then the services that are called synchronously. Measure before you change anything.

Name common performance mistakes.

Calling the catalog or customer API once per item inside a loop, reading huge result sets instead of paginating or using search, forgetting to close iterators, making external calls on every page view without caching or timeouts, and putting personal data into cacheable pages.

How do you test SFCC code?

Unit-test pure logic (helpers, decorators) with a test runner and mocks for dw/* modules, since the platform classes do not exist locally. Add integration tests against a sandbox and, for headless storefronts, normal front-end tests. Keep business logic in small functions that take plain data. See Testing, Debugging and Logging.

Two runnable stand-ins

These illustrate answers above. They are not the Script API.

JS module.superModule: extending along the cartridge path

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The result is CART PAGE + gift box, produced by three modules that never copied each other's code. The plugin calls the brand module, which calls the base. If the base changes its show, the plugin and the brand still pick up the change.

JS A service with a timeout and a circuit breaker

Press Run (or Ctrl + Enter) to see the console output here.

No output.

After three timeouts the breaker opens, so the calls at 4 and 20 are skipped and the shopper gets a fallback instead of waiting. At 35 the cool-down has passed, one trial call succeeds, and the breaker closes. The real service framework offers circuit-breaker and rate-limit settings in the service profile; the exact options are configured in Business Manager, so confirm them in the documentation for your release.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A template exists in two cartridges. How does the platform choose?

    The cartridge path is searched left to right and the first match is used. The others are shadowed.
  2. 2. Which is the best way to add a field to the Cart-Show view data from a plugin?

    Appending adds behavior around the base route, so base updates still apply and your change stays separate.
  3. 3. Which authentication service issues shopper tokens for SCAPI?

    SLAS, the Shopper Login and API Security Service, issues guest and registered shopper tokens.
  4. 4. What is the main safeguard against an export job creating duplicate records after a crash?

    When a repeat of the same work is harmless, a crash between a call and a save cannot cause duplicates.
  5. 5. Why should personal content stay out of a cached page?

    A shared cache entry is delivered to many visitors. Load personal parts separately, for example with a remote include that has its own rules.

Summary

  • Customize with overlay cartridges to the left of the base, never by editing the base.
  • SFRA routes are chains of steps; extend them with append, prepend and module.superModule rather than copying.
  • Use hooks for platform extension points, the service framework for third-party calls, and credentials for secrets.
  • SCAPI with SLAS is the modern API route for headless storefronts; OCAPI is the older family.
  • Make jobs idempotent, cache by complete keys, keep personal data out of shared pages and measure before optimizing.

Next: SFCC Cheat Sheet