Free practice · No sign-up required

Salesforce CCD-102 B2C Commerce Developer with SFRA free practice test

20 questions with answer explanations. Choose an answer below to begin.

Question 1 of 20

In SFRA, which layer is responsible for handling client requests and returning responses?

Show hint

Understand SFRA architecture and MVC pattern

0/20 answered · Bookmark questions to review later. Focus the practice area to use keys 1–9 and Enter.

Learn by doing

Put your answers into practice

Use official documentation and hands-on labs to work through topics you missed.

Explore all study resources →

All questions and explanations

Prefer to read at your own pace? Work through each question below, then open its answer to check your reasoning. You can link directly to a question or print this reference.

  1. In SFRA, which layer is responsible for handling client requests and returning responses?

    1. Controller (JavaScript files)

    2. View (ISML templates)

    3. Model (custom objects)

    4. Service (external integrations)

    Show answer and explanation

    Correct answer

    • Controller (JavaScript files)

    Controllers in SFRA handle incoming HTTP requests, process data, and return responses. Views handle rendering, models represent data, and services communicate with external systems.

  2. Which method is automatically called in an SFRA controller when a GET request is made?

    1. start()

    2. init()

    3. show()

    4. get()

    Show answer and explanation

    Correct answer

    • init()

    In SFRA controllers, the `init()` method is executed before any action for both GET and POST requests. There is no `show()` or `get()` method by default; actions are defined as methods and mapped via routes.

  3. Where should form field validation rules be defined in SFRA?

    1. In the controller action

    2. In the ISML template

    3. In the form model definition file

    4. In the routes configuration

    Show answer and explanation

    Correct answer

    • In the form model definition file

    Form validation rules are defined in the form model file (e.g., `forms/default/myForm.json`). The controller may invoke validation, but the rules themselves are part of the form model. Templates only render forms, and routes map URLs.

  4. Which ISML directive is used to include another template file within a template?

    Show answer and explanation

    Correct answer

    The `` directive includes another ISML template at that point. `isimport` and `isrequire` are not valid directives. `isinsert` is used for decorator templates.

  5. What is the base class that a custom SFRA service should extend?

    1. LocalServiceRegistry

    2. BaseService

    3. Service

    4. AbstractService

    Show answer and explanation

    Correct answer

    • LocalServiceRegistry

    In SFRA, services are created using `LocalServiceRegistry.createService()`, and the service object extends the base service provided by the registry. There is no `BaseService` or `AbstractService` class; the registry handles the base functionality.

  6. What is the purpose of the `@after` decorator in an SFRA controller?

    1. To execute code after a response is sent

    2. To define a hook that runs after the main action

    3. To set a cookie in the response

    4. To validate form data after submission

    Show answer and explanation

    Correct answer

    • To define a hook that runs after the main action

    The `@after` decorator registers a function to be called after a specific controller action, often used for post-processing. It does not run after the response is sent (that would be a middleware), and it is not for cookie setting or validation.

  7. When extending a base SFRA model, which method should be overridden to include custom attributes in the output?

    1. getData()

    2. serialize()

    3. toJSON()

    4. getAttributes()

    Show answer and explanation

    Correct answer

    • toJSON()

    The `toJSON()` method is used to serialize model data. Overriding it allows you to include custom attributes. `getData()` and `getAttributes()` are not standard. `serialize()` is not a model method in SFRA.

  8. What is the difference between `InputField` and `SelectField` in SFRA form definitions?

    1. InputField is for numeric values; SelectField is for string values

    2. InputField is used for GET forms; SelectField for POST forms

    3. InputField requires validation; SelectField does not

    4. InputField accepts text input; SelectField provides a dropdown

    Show answer and explanation

    Correct answer

    • InputField accepts text input; SelectField provides a dropdown

    In SFRA form models, `InputField` renders a text input, while `SelectField` renders a dropdown (select) element. Both support validation, and the form method (GET/POST) does not affect field type.

  9. In a SFRA job, which step type allows you to execute custom JavaScript code?

    1. Script step

    2. Custom step

    3. Pipeline step

    4. Java step

    Show answer and explanation

    Correct answer

    • Script step

    The 'Script step' in a job allows execution of custom JavaScript code (or other scripts). 'Custom step' is not a job step type in SFRA; pipeline steps are for pipelines, and Java steps are not used.

  10. Question 10

    Link to question

    A developer needs to add a new locale (e.g., fr-CA) that is not in the default list. What is the recommended approach in SFRA?

    1. Add the locale to the site's allowed locales in Business Manager

    2. Create a new cartridge with locale-specific properties

    3. Modify the system's locale configuration file

    4. Override the locale service to include the new locale

    Show answer and explanation

    Correct answer

    • Create a new cartridge with locale-specific properties

    The recommended approach is to create a new cartridge with locale-specific properties and settings. Adding to allowed locales is needed but not sufficient; the locale must be supported by custom resources. Modifying system files is not recommended, and overriding the locale service is unnecessary.

  11. Question 11

    Link to question

    A custom OCAPI data endpoint returns product data. For security and performance, where should cache expiration be set?

    1. In the service definition JSON file

    2. In the controller action using `response.setExpires()`

    3. In the OCAPI settings in Business Manager

    4. In the API's resource hook

    Show answer and explanation

    Correct answer

    • In the OCAPI settings in Business Manager

    Cache expiration for OCAPI endpoints is configured in Business Manager under OCAPI settings. Setting it in the controller is not the standard way as OCAPI handles caching at the API level. Service definitions and resource hooks are for other purposes.

  12. Question 12

    Link to question

    How should a developer access site preferences (custom site attributes) in an SFRA controller?

    1. Using `session.custom.sitePreferences`

    2. Using `request.custom.sitePreferences`

    3. Using `app.getSite().preferences`

    4. Using `require('dw/system/Site').getCurrent().getCustomPreferenceValue()`

    Show answer and explanation

    Correct answer

    • Using `require('dw/system/Site').getCurrent().getCustomPreferenceValue()`

    The correct way is via the `Site` API: `Site.getCurrent().getCustomPreferenceValue()`. Preferences are not available on session or request objects directly. `app.getSite()` is not a valid API in SFRA.

  13. Question 13

    Link to question

    A developer wants to modify the product search results to boost certain products. Which SFRA hook should be used?

    1. ProductSearch.beforeSearch

    2. ProductSearch.modifySearchResult

    3. Search.afterSearch

    4. ProductSearch.afterSearch

    Show answer and explanation

    Correct answer

    • ProductSearch.beforeSearch

    The `ProductSearch.beforeSearch` hook allows modification of search parameters before the search is executed. `afterSearch` would run after results are returned, not ideal for boosting. `modifySearchResult` is not a standard hook.

  14. Question 14

    Link to question

    When migrating a legacy pipeline to an SFRA controller, what is the recommended approach?

    1. Rewrite the pipeline as a single controller action

    2. Convert pipeline steps into separate controller endpoints

    3. Use the PipelineController to wrap the pipeline

    4. Import the pipeline as a service

    Show answer and explanation

    Correct answer

    • Convert pipeline steps into separate controller endpoints

    The best practice is to convert each pipeline step into a separate controller endpoint, leveraging SFRA's MVC pattern. Using a single action defeats modularity, and PipelineController is not a standard SFRA component. Importing as a service is not appropriate.

  15. Question 15

    Link to question

    A custom service in SFRA needs to log request/response details for debugging. What is the best way to add logging?

    1. Override the service's `logRequest` method

    2. Use the `afterRequest` hook in the service definition

    3. Add `require('dw/system/Logger').getLogger()` calls in the service callback

    4. Configure logging in the Business Manager service settings

    Show answer and explanation

    Correct answer

    • Add `require('dw/system/Logger').getLogger()` calls in the service callback

    The `Logger` API is the standard way to add logging in a service callback. There is no `logRequest` method or `afterRequest` hook for services. Business Manager settings are for the server log configuration, not per-service logging.

  16. Question 16

    Link to question

    An order is placed and the developer needs to send order data to an external system. Should an order hook or a job be used?

    1. Use a job because it can handle failures and retries

    2. Use a hook because it executes synchronously and ensures data is sent before response

    3. Use a job to avoid adding latency to the checkout

    4. Use a hook for immediate action, and a job for additional processing if needed

    Show answer and explanation

    Correct answer

    • Use a hook for immediate action, and a job for additional processing if needed

    Hooks are ideal for immediate, synchronous actions but can add latency. Jobs are better for asynchronous, reliable processing with retries. The best practice often combines both: a hook for immediate action (e.g., logging) and a job for heavier processing (e.g., external sync).

  17. Question 17

    Link to question

    A custom product feed is generated daily and takes 10 minutes. To improve performance, what caching strategy should be applied?

    1. Use Serialized file caching

    2. Use Service Worker cache

    3. Use Server-side caching with a brief TTL

    4. Use Client-side caching with ETags

    Show answer and explanation

    Correct answer

    • Use Serialized file caching

    For a batch-generated feed, serialized file caching (e.g., storing the feed as file in the application's cache directory) is appropriate because the feed is static between generations. Server-side caching with TTL is useful for dynamic data but less efficient for large files. Client-side caching is not applicable for server-side processing.

  18. Question 18

    Link to question

    A custom form in SFRA submits data via POST. What must be included to prevent CSRF attacks?

    1. The form must use HTTPS

    2. A CSRF token in the form as a hidden field

    3. Set `SameSite` cookie attribute

    4. Validate the request origin header

    Show answer and explanation

    Correct answer

    • A CSRF token in the form as a hidden field

    CSRF protection in SFRA is implemented by including a CSRF token in the form (typically via `dw.web.CSRFProtection`). HTTPS and SameSite cookies add security but are not sufficient alone. Origin header validation is not standard in SFRA.

  19. Question 19

    Link to question

    A custom model is used across multiple sites in a multi-site environment. How should the model be shared to avoid duplication?

    1. Place the model cartridge in the site path of each site

    2. Create the model as a plugin cartridge and assign it to all sites

    3. Use a shared library cartridge

    4. Duplicate the model code in each site's custom cartridge

    Show answer and explanation

    Correct answer

    • Use a shared library cartridge

    A shared library cartridge is the recommended approach for sharing code across sites. Placing the cartridge in each site path works but leads to duplication. Plugin cartridges are for functionality, not specifically for sharing models. Duplication is bad practice.

  20. Question 20

    Link to question

    A controller error occurs and the developer wants to display a custom error page. What is the best approach for global error handling in SFRA?

    1. Catch exceptions in each controller action and render a custom template

    2. Override the `handleError` function in the base controller

    3. Set up error handling in the route configuration

    4. Use the global error handler middleware in the server configuration

    Show answer and explanation

    Correct answer

    • Use the global error handler middleware in the server configuration

    SFRA provides a global error handler middleware that can be configured to catch errors and render custom error pages. Catching in each action is repetitive and not maintainable. Overriding `handleError` is not standard. Route configuration does not handle errors.

Read all flashcards

Recall the answer before opening each card.

Which SFRA layer handles client requests and returns responses?

Controller. Controllers process HTTP requests and return responses; views handle rendering, models represent data.

What method runs automatically in a controller for both GET and POST requests?

init(). The init() method executes before any action method, regardless of HTTP method.

Where are form field validation rules defined in SFRA?

In the form model definition file (e.g., forms/default/myForm.json). Rules are part of the model, not the controller or template.

Which ISML directive includes another template file?

The isinclude directive. It inserts the content of another template at the point of inclusion.

What base class should a custom SFRA service extend?

LocalServiceRegistry. Services are created via LocalServiceRegistry.createService(), which provides the base service object.

What does the @after decorator do in a controller?

It registers a function to run after the main action. Used for post-processing hooks.

Which method should be overridden to include custom attributes in model output?

toJSON(). Overriding toJSON() allows custom serialization of model data.

What is the difference between InputField and SelectField?

InputField renders a text input; SelectField renders a dropdown (select) element.

Which job step type executes custom JavaScript code?

Script step. The Script step allows running custom JavaScript or other scripts.

How to add a new locale like fr-CA in SFRA?

Create a new cartridge with locale-specific properties and place it in the site path.

Where should OCAPI cache expiration be configured?

In Business Manager under OCAPI settings. Not in controllers or service definitions.

How to access custom site preferences in a controller?

Use require('dw/system/Site').getCurrent().getCustomPreferenceValue('name').

Which SFRA hook modifies product search parameters before execution?

ProductSearch.beforeSearch. It allows boosting or filtering before the search runs.

What is the recommended approach to migrate a legacy pipeline to SFRA?

Convert each pipeline step into a separate controller endpoint, leveraging MVC modularity.

How to add logging in a custom service?

Add require('dw/system/Logger').getLogger() calls inside the service callback.

Should you use a hook or a job for immediate external system notification after order?

Use a hook for immediate action, and a job for additional async processing if needed.

What caching strategy suits a daily batch-generated product feed?

Serialized file caching. Store the feed as a file in the cache directory between generations.

What must be included in a POST form to prevent CSRF?

A CSRF token as a hidden field, generated by dw.web.CSRFProtection.

How to share a custom model across multiple sites without duplication?

Use a shared library cartridge. Place the cartridge in each site's cartridge path.

What is the best approach for global error handling in SFRA?

Use the global error handler middleware configured in the server.js file.

Active recall deck

Practice Salesforce CCD-102 B2C Commerce Developer with SFRA with real flashcards

Read the prompt, commit to an answer, then flip the card. Move through the deck at your own pace and repeat any topic that does not come back quickly.

20 free cards

Card 1 of 20

1 reviewed this session

Connect the concepts

Your Salesforce CCD-102 B2C Commerce Developer with SFRA study mind map

Open a branch to connect a topic with its practice questions and explanations. Use the map to choose your next review topic.

Salesforce CCD-102 B2C Commerce Developer with SFRA20 questions in this practice set
Understand SFRA architecture and MVC pattern(1)
Describe SFRA controller lifecycle and request handling(1)
Implement form validation in SFRA(1)
Understand ISML template syntax and includes(1)
Describe service creation in SFRA(1)
Use decorators in SFRA controllers(1)
Extend SFRA models and customize serialization(1)
Identify form field types in SFRA(1)
Describe job step types in SFRA(1)
Implement localization for additional locales in SFRA(1)
Configure OCAPI settings for caching and security(1)
Access site preferences in controllers(1)
More practice connections(8)
Exam-focused analysis

What this CCD-102 practice set measures

This is an analysis of the practice bank, not a claim about the vendor's live exam blueprint. Use it to identify the knowledge, judgment, and recall patterns exercised here, then verify your coverage against the current official exam guide.

1. SFRA Architecture and Controller Patterns

Questions 1–3 and 6–7 focus on SFRA’s MVC layers and controller mechanics. You must understand that controllers handle requests and return responses, the init() method runs before actions, decorators like @after run after the main action, and model’s toJSON() is overridden for custom serialization. Form validation rules live in form model files, not controllers or templates. These questions test your grasp of separation of concerns and the framework’s lifecycle.

  • Controllers process HTTP requests; views render; models represent data.
  • init() runs before any action; @after hook runs after the action.
  • Form validation rules are defined in the form model JSON file.
  • Override toJSON() on a model to include custom attributes in output.

2. Services, Hooks, and Job Steps

Questions 4–5 and 9–10 and 13 cover service creation (extending LocalServiceRegistry), ISML template inclusion (isinclude directive), job step types (Script step runs custom JavaScript), localization (create new cartridge for new locale), and search customization (ProductSearch.beforeSearch hook). These items test your ability to integrate external systems, automate tasks, and extend built-in functionality through hooks and services.

  • Custom services extend LocalServiceRegistry via createService().
  • Use isinclude to include another template file in ISML.
  • Script steps in jobs execute custom JavaScript code.
  • For a new locale, create a cartridge with locale-specific properties.
  • ProductSearch.beforeSearch hook modifies search parameters before execution.

3. Data Access, Caching, and Security

Questions 11–12 and 17–18 address OCAPI caching (set in Business Manager), site preferences (Site.getCurrent().getCustomPreferenceValue()), caching strategies (serialized file caching for batch feeds), and CSRF protection (include CSRF token as hidden field). You need to know where configurations live, how to access custom attributes, and which security measures are standard in SFRA.

  • OCAPI cache expiration is configured in Business Manager settings.
  • Access site preferences via dw/system/Site API, not session or request.
  • Serialized file caching is suitable for static batch-generated feeds.
  • CSRF token must be added as a hidden field in POST forms.

4. Migration, Code Sharing, and Error Handling

Questions 14, 19, and 20 cover pipeline migration (convert steps to separate controller endpoints), multi-site code sharing (use a shared library cartridge), and global error handling (configure global error handler middleware). These questions test your ability to modernize legacy code, avoid duplication across sites, and implement consistent error responses.

  • Migrate pipelines by converting each step into a separate controller action.
  • Share models across sites using a shared library cartridge.
  • Global error handling is best done via server configuration middleware.
  • Avoid modifying system files; use cartridge-based customization.

Study workflow

Turn one CCD-102 attempt into a study plan

  1. 1

    Identify the Request Handling Layer

    When a client request arrives, determine if it should be handled by a controller or a custom service. Controllers handle user-facing interactions and return views or JSON. Services handle external system communication or complex business logic. Always start by mapping the request to the correct SFRA layer.

  2. 2

    Implement Form Validation

    Create a form model JSON file under forms/default/ and define fields with validation rules (required, minLength, etc.). In the controller action, use form.get() to retrieve the model and form.isValid() to check. Avoid putting validation logic in templates; keep it in the model definition.

  3. 3

    Cache Static Resources Efficiently

    For batch-generated content like product feeds, use serialized file caching by writing the output to a cache file and serving it until the next generation. For dynamic data, consider server-side caching with a TTL. Monitor cache hit rates and adjust TTLs to balance freshness and performance.

  4. 4

    Add CSRF Protection to Forms

    In the controller that renders the form, generate a CSRF token using dw.web.CSRFProtection and pass it to the template. In the template, include it as a hidden input field named csrf_token. On form submission, verify the token in the controller before processing data.

  5. 5

    Set Up Global Error Handling

    In the server configuration file (server.js), add a global error handler middleware using app.use with a callback that catches errors and renders a custom error template. Log the error with Logger for debugging. This centralizes error responses and avoids repetitive try-catch blocks.

FAQ

Questions about this CCD-102 practice page

Clear boundaries on what the bank covers, how to use it, and where official vendor information still matters.

What is the role of the init() method in an SFRA controller?+

The init() method runs automatically before any action, regardless of HTTP method. It is used for common setup like session validation or setting up pre-requisites. It is not an action itself but a lifecycle hook that executes before action methods.

How do I create a custom service in SFRA that logs request and response?+

Use require('dw/system/Logger').getLogger() inside the service callback to log details. Call Logger methods for request/response data. There is no built-in logRequest method; you must add logging explicitly in the callback function.

What is the recommended way to share code across multiple sites in a multi-site environment?+

Create a shared library cartridge that contains common models, services, and scripts. Assign that cartridge to the site's cartridge path. This avoids code duplication and simplifies maintenance. Do not copy code into each site's cartridges.

Can I use a single controller action to handle multiple pipeline steps during migration?+

No. Best practice is to convert each pipeline step into a separate controller endpoint. This leverages SFRA's modular MVC pattern, making the code easier to maintain and test. A single action would defeat the purpose of migration.

How do I customize product search results to boost certain products?+

Use the ProductSearch.beforeSearch hook. In the hook implementation, modify the search parameters (like boosting criteria) before the search is executed. The afterSearch hook runs after results and is not suitable for boosting.

Keep studying

Build the next review session

Browse another free bank or use the study strategy guide to turn your misses into spaced review.