Salesforce-B2C-Commerce-Cloud-Developer Practice Test Questions

202 Questions


A developer is working on a new site for the U.S based on an existing Canadian site. One of the requirements is a change to the address form. The current Canadian form has an list with the correct two-letter abbreviation for the provinces.
The U.S. requirements are to:

• Have an list with the correct two-letter abbreviation for the states in place of the province field.
• Set the U.S site locale.
• Add the options list field definition to the XML file.

How should the developer set up the files before making the required edits?


A. Create a copy of existing address.xml file in the default folder. Rename that file to adres_US.xml


B. Create a new sub-folder in the forms folder. Name it US. Copy existing address.xml file in the new folder


C. Create a copy of existing address.xml file in the default folder. Rename that file to address_en_US.xml


D. Create a new sub-folder in the forms folder. Name it en_US. Copy existing address.xml file in the new folder.





D.
  Create a new sub-folder in the forms folder. Name it en_US. Copy existing address.xml file in the new folder.

Explanation:

This question tests understanding of B2C Commerce locale-specific form customization using the site hierarchy.

Key Requirements
Modify the address form for the U.S. site.
Set the U.S. site locale (implied to be en_US).
Add or modify the field definition in the XML file.
The correct approach leverages the locale-based file resolution system in B2C Commerce.

How Form File Resolution Works
Forms are stored in forms/<locale>/. The system resolves the form file based on the current site's locale settings. The hierarchy typically is:
forms/<site_locale>/<form_name>.xml → forms/default/<form_name>.xml

Therefore, to customize the address.xml form specifically for the U.S. site (with locale en_US), you must:
Create the locale-specific folder: forms/en_US/.
Copy the base address.xml file from forms/default/ into this new folder.
Edit the copied file (forms/en_US/address.xml) to replace the province list with the U.S. states list.

This ensures that when the U.S. site (locale en_US) renders the address form, it automatically uses the customized version, while the Canadian site continues to use the default or an en_CA version.

Why the Other Options Are Incorrect
A. Create a copy of existing address.xml file in the default folder. Rename that file to adres_US.xml:
This is incorrect for multiple reasons. First, placing it in the default folder is not locale-specific. Second, renaming the file breaks the standard naming convention (address.xml). The system looks for a file named address.xml, not adres_US.xml.

B. Create a new sub-folder in the forms folder. Name it US. Copy existing address.xml file in the new folder:
The folder name must be a valid locale ID (like en_US, fr_CA, de_DE). US is not a valid locale ID. The system will not automatically resolve to this folder based on the site's locale setting.

C. Create a copy of existing address.xml file in the default folder. Rename that file to address_en_US.xml:
Similar to option A, this places the file in the wrong location (default folder) and uses an incorrect filename. The system expects the file to be named address.xml inside a locale-specific folder, not a locale-suffixed filename inside the default folder.

Key Concepts
Form Localization: B2C Commerce documentation describes how forms are resolved based on locale folders (forms/<locale>/) to support multi-region and multi-language sites.
Locale ID Standards: Locale IDs follow the pattern language_COUNTRY (for example, en_US, en_GB, fr_CA). This is what the site's locale is set to in Business Manager.
Site-Specific Customization: The correct method is non-destructive and upgrade-safe. You override only the specific form for the specific locale by placing a copy in the appropriate folder, leaving the base (default) form intact for other locales.

Summary
To customize a form for a specific locale (en_US), create a folder named after that locale inside forms/, copy the base XML file there, and modify the copy. This is the standard, documented best practice.

A Digital Developer is implementing an Open Commerce API call to add products to a basket. Given the following resource configuration:

Which modification allows the requests to successfully execute?


A. Change the "resource_id" value to: "/baskets/*/items"


B. Change the "write_attributes" value to: "(+items)"


C. Change the "read_attributes" value to: "(items)"


D. Change the "methods" value to: ["get", "post"]





D.
  Change the "methods" value to: ["get", "post"]

Explanation
The developer wants to add products to a basket using Open Commerce API (OCAPI).

Key OCAPI Rule
Adding items to a basket requires an HTTP POST request.
GET is read-only and cannot modify basket contents.

Given the resource configuration:
{
  "resource_id": "/baskets/**",
  "methods": ["get"],
  "read_attributes": "(**)",
  "write_attributes": "(**)"
}

The problem is that POST is not allowed, so any request that attempts to add products will fail due to insufficient permissions.

The Fix
Allow POST in the methods configuration:
"methods": ["get", "post"]

This enables successful execution of requests that add items to the basket.

Why the Other Options Are Incorrect
A. Change resource_id to /baskets/*/items ❌
While /baskets/{basketId}/items is the endpoint used to add items, the wildcard /baskets/** already covers this path. The issue is not the resource path.

B. Change write_attributes to (+items) ❌
Write attributes control what fields may be written, not whether the request method is allowed. Without POST, the call still fails.

C. Change read_attributes to (items) ❌
Read attributes affect response visibility only and have no impact on adding products.

Reference
OCAPI Basket Items – Add Product to Basket
OCAPI Settings (Methods and Permissions)

A Digital Developer has identified that the code segment below is causing performance problems.



What should the Developer do to improve the code?


A. Use a system attribute instead of the isOnSaleFlag custom attribute.


B. Avoid post-processing and use the isOnSaleFlag attribute as a search refinement.


C. Breaks the process into separate loops.


D. Avoid using an Iterator and use a Collection instead.





B.
  Avoid post-processing and use the isOnSaleFlag attribute as a search refinement.

Explanation:

The performance issue comes from post-processing search results in a loop:

while (productSearchHits.hasNext()) {
  foundProduct = productSearchHits.next();
  if (foundProduct.custom.isOnSaleFlag == "true") {
    results.add(foundProduct);
  }
}

What’s Happening
The product search returns all products.
The code then iterates through every result.
Filtering (isOnSaleFlag) happens in application code, not at the search level.
This is inefficient, especially for large catalogs.

Best Practice in B2C Commerce
Always filter at the search level whenever possible.
If isOnSaleFlag is a searchable or refinable custom attribute, it should be used as a search refinement in the product search model instead of filtering after the fact.

Benefits
Fewer products returned.
Less iteration.
Better performance.
Uses the platform’s optimized search index.

This directly addresses the performance issue.

Why the Other Options Are Incorrect
A. Use a system attribute instead of the custom attribute
Custom attributes can be indexed and refined just like system attributes. The issue is where filtering occurs, not the attribute type.
C. Break the process into separate loops
This would make performance worse, not better.
D. Avoid using an Iterator and use a Collection instead
The iterator is not the performance problem. The problem is processing too many results.

Reference
Salesforce B2C Commerce – Product Search and Refinements
Performance Best Practices – Avoid Post-Processing

A developer has the following files in template/resources:

account.proierties
weight.unit=kilos
account_en.propierties
weight.unit=stones
account_en_US.propierties
weight.unit= pounds

Using the default locale configuration, what is the current outcome of the page that renders the account.isml template snippet below when visiting the Sofrefront with the English for Canada(en_CA) locale=
Your parcel weighs 10 ${Resource.msg(‘weight.unit’,’account’)}


A. Your parcel weighs 10 stones.


B. Your parcel weighs 10 pounds


C. Your parcel weighs 10 undefined.


D. Your parcel weighs 10 kilos





A.
  Your parcel weighs 10 stones.

Explanation:

This question tests understanding of B2C Commerce's locale fallback logic for resource property files.

File Structure & Locale Analysis
account.properties – The default/base file (no locale suffix). Contains weight.unit=kilos.
account_en.properties – The file for the language English (en). Contains weight.unit=stones.
account_en_US.properties – The file for the specific locale English - United States (en_US). Contains weight.unit=pounds.

Current Site Locale: The user is visiting with locale en_CA (English - Canada).

Locale Resolution Hierarchy
B2C Commerce resolves resource messages using a specific-to-general fallback:
Exact locale match: account_en_CA.properties → NOT FOUND.
Language match: account_en.properties → FOUND! (en matches the language part of en_CA).
Default file: account.properties → This is only used if no language-specific file is found.

Since account_en.properties exists, the system will use the value from that file (weight.unit=stones). It does not fall back to the base account.properties because a valid language match (en) was found.

Template Execution
The line ${Resource.msg('weight.unit','account')} looks up the key weight.unit from the account bundle.
Following the resolution logic for en_CA, it retrieves the value stones from account_en.properties.

Therefore, the rendered text is: "Your parcel weighs 10 stones."

Why the Other Options Are Incorrect
B. Your parcel weighs 10 pounds
This would be correct only if the locale was en_US, as it uses account_en_US.properties.

C. Your parcel weighs 10 undefined
This would only happen if the key weight.unit was missing from all resolved property files (including the base default). It is found in account_en.properties.

D. Your parcel weighs 10 kilos
This would be correct only if there were no account_en.properties file, forcing a fallback to the base account.properties. Since account_en.properties exists, it takes precedence for any en_* locale.

References:
Resource Bundle Localization Fallback: The system searches in this order for a given locale {language}_{country}:
bundle_{language}_{country}.properties
bundle_{language}.properties
bundle.properties

Locale-Specific Customization: This mechanism allows developers to provide translations/regional variations for different markets while maintaining a common base.
Resource.msg() Method: The method parameters are (key, bundleName, locale?). If no locale is specified, it uses the current request's locale.

Summary
For locale en_CA, the system resolves to the language-level file account_en.properties, returning "stones".

A Digital Developer adds the following line of code to a script



The code executes without error; however, the log file on disk does NOT contain the log message. Which two actions should be completed to write the log message to disk? (Choose two.)


A. Ensure that the debug log level is enabled to write to file in the Custom Log Settings Business Manager module


B. Archive old log files to make room in the log directory.


C. Ensure that the “login” category is added to the Custom Log Filters in the Log Settings Business Manager module.


D. Ensure that the debug log level has been added to the custom log level types in the Global Preferences business manager module





A.
  Ensure that the debug log level is enabled to write to file in the Custom Log Settings Business Manager module

C.
  Ensure that the “login” category is added to the Custom Log Filters in the Log Settings Business Manager module.

Explanation
The code:
dw.system.Logger.getLogger('login').debug('Login API has succeeded');

executes correctly, but no log entry appears on disk.
In Salesforce B2C Commerce, for a log message to be written to disk, two independent configurations must allow it:

Required Configurations
A. Debug log level must be enabled
debug() messages are not written by default in many environments.
In Business Manager → Administration → Operations → Custom Log Settings, the DEBUG log level must be enabled for file output.
If DEBUG is disabled, the message is silently ignored.

C. The login category must be allowed
getLogger('login') uses login as the log category.
Categories must be explicitly listed in Custom Log Filters.
If the category is missing, no log entry is written, even if the log level is enabled.

Why the Other Options Are Incorrect
B. Archive old log files
Log rotation and disk space are handled automatically. Lack of space would cause errors, not silent failures.

D. Add debug log level to Global Preferences
DEBUG is a standard log level. You do not need to define it as a custom level.

Reference
Salesforce B2C Commerce – Logging Configuration
Custom Log Settings & Filters

Given the code snippet aboce, what should be added after this code so it can be used for page component display?


A. Base.render = render;


B. Module.exports.render = render;


C. Module.exports = render;


D. Module.exports = server.exports();





D.
  Module.exports = server.exports();

Explanation
In Salesforce B2C Commerce SFRA (Storefront Reference Architecture), page components (also called "ISML components", "renderable modules", or "cartridge modules") are small, reusable pieces of functionality that can be rendered via controllers or included directly in templates using <isinclude template="...">.

Why B is Correct
module.exports.render = render;
→ This is the exact convention used in SFRA for page components.
→ When a template includes <isinclude template="components/myComponent" />, SFRA looks for a file cartridge/components/myComponent.js (or in app_storefront_base, etc.).
→ It then calls the exported function named render and passes a context object to it.
→ This allows the component to render its own ISML template and populate the context if needed.

Why the Other Options Are Incorrect
A. Base.render = render;
→ There is no global Base object in SFRA page components. This is invalid and would throw an error.

C. Module.exports = render;
→ This overwrites the entire module export with just the function.
→ SFRA expects an object with a render property (i.e., { render: function }).
→ Exporting the function directly breaks the component loading mechanism.

D. Module.exports = server.exports();
→ server.exports() is used in controllers (not page components).
→ Controllers register routes with server.get(), server.post(), etc., and export the whole server instance.
→ Page components do not use routes — they only need to export a render function.

A Digital Developer needs to add a new form to the shopping cart page to allow customers to enter their rewards pass ID. There is already an existing Cart.js controller that handles processing of the other cartforms. In addition, a form field node is in the form XML and the necessary form input is present in the ISML template. The code below is the submit button for the ISML markup.


A. Option A


B. Option B


C. Option C


D. Option D





A.
  Option A

Explanation:

Why Option A is Correct
In SFCC form handling (the classic Forms Framework used with pdict.CurrentForms and Form.handleAction()), a submit button like:

<button type="submit"
    value="${pdict.CurrentForms.cart.addRewardPass.htmlName}"
    name="${pdict.CurrentForms.cart.addRewardPass.htmlName}">
    ${Resource.msg('rewards.apply','locale',null)}
</button>

is designed to trigger a form action named addRewardPass.

For that action to work, two things must exist:
1. The action must be declared in the form XML
   Add an <action /> node under the cart form definition with:
   formid="addRewardPass"
2. The controller must map that action to a handler function
   In Cart.js, where it calls Form.handleAction(), add a key named addRewardPass whose value is the function that processes the request.

That’s exactly what Option A describes.

Why the Other Options Are Wrong
B ❌ Uses <submit /> — that is not the form-action node used for this framework.
C ❌ addtl-form-action is not the documented requirement here; the framework relies on the form XML <action> plus Form.handleAction() mapping.
D ❌ If you add an action to the XML but don’t add the handler mapping in the controller, the submit won’t be processed correctly.

A developer needs to show only car accessories when shoppers use the search term car accessories and exclude technology accessories and household accessories. Given the above requirement, what is the recommended approach using the Search Dictionaries Dashboard?


A. Create a Synonym Dictionary entry: car accessories, household, technology.
Use search mode Exact Match


B. Create a Common Phrase Dictionary entry: car accessories, NOT household, NOT technology. Use search mode Exact Match.


C. Create a Synonym Dictionary entry: car accessories, household, technology. Use search mode First Word.


D. Create a Common Phrase Dictionary entry: car accessories.
Use search mode Exact Match





D.
  Create a Common Phrase Dictionary entry: car accessories.
Use search mode Exact Match

Explanation:

This question tests the understanding of Search Dictionaries and their correct application for search term precision.

The requirement is: Show only car accessories when shoppers use the search term "car accessories", and exclude technology accessories and household accessories.

Purpose of Each Dictionary Type
Common Phrase Dictionary: This is used to treat a specific multi-word phrase as a single, precise search term. When "Exact Match" mode is used, it ensures that results are returned only when the shopper enters that exact phrase. It does not add synonyms or variations.

Synonym Dictionary: This is used to expand a search term to include synonyms or related terms. For example, mapping "car" to "automobile, vehicle". This is the opposite of the requirement, as it would broaden, not narrow, the results.

Why Option D is Correct
Common Phrase Dictionary entry: "car accessories" tells the search engine to treat "car accessories" as one specific unit.
Search mode: Exact Match ensures that this dictionary entry only applies when the shopper types the phrase exactly as defined ("car accessories"). It will not trigger on "accessories for car" or "car and accessories".
Result: When a user searches for the exact phrase "car accessories", the search engine looks for products explicitly matching that phrase. Since "technology accessories" and "household accessories" are different phrases, they are naturally excluded. The dictionary does not need to contain "NOT" statements; its precise matching inherently provides the required filtering.

Why the Other Options Are Incorrect
A & C: Create a Synonym Dictionary entry...
A synonym dictionary would add "household" and "technology" as alternative search terms when someone searches for "car accessories". This would cause the search to return household and technology accessories, which is the exact opposite of the requirement.

B: Create a Common Phrase Dictionary entry: car accessories, NOT household, NOT technology
This syntax is invalid. Common Phrase entries do not support Boolean operators (NOT, AND, OR) within the phrase definition. Boolean logic is handled at the query level, not in the search dictionary. The dictionary's job is to define the phrase, not to apply query logic.

Key References & Concepts
Search Dictionaries Documentation:
- Common Phrase: Used for precise phrase matching (e.g., brand names, specific product lines). "Exact Match" mode is for precision.
- Synonym: Used for broadening searches by linking related terms.

Exact Match vs. First Word Mode: "Exact Match" requires the entire phrase. "First Word" mode would apply the rule if the phrase starts with the defined words, which could cause unintended matches.

Achieving Precision: To restrict results to a very specific category, you use a Common Phrase Dictionary with Exact Match. This ensures the search is interpreted literally, not expanded.

Summary
To guarantee that the search term "car accessories" returns results for only that category and excludes others, define it as a Common Phrase with Exact Match. This uses the search dictionary for its intended purpose: precise phrase recognition, not Boolean filtering.

A client sells its product in single-brand stores as well as in multi-brand stores. When shown in the store locator list, the client wants the single-brand stores to have a particular background color to highlight them.
Which Business Manager action should be completed to allow the developer to apply different styling to the single-brand stores?


A. Add a Boolean custom attribute to the Store system object


B. Configure the existing Store custom object type definition


C. Create a new SingleBrandStore custom object configuration


D. Adjust the relevant Site Preference in the Stores group





A.
  Add a Boolean custom attribute to the Store system object

Explanation:

The requirement calls for distinguishing between single-brand and multi-brand stores in the store locator for styling purposes. The most efficient and architecturally sound approach is to extend the existing Store system object with a custom attribute. B2C Commerce allows developers to add custom attributes to system objects like Store through Business Manager. By creating a Boolean custom attribute (e.g., isSingleBrand), merchants can flag each store accordingly. This attribute then becomes available in the store data model, enabling the front-end developer to access it via the Store API and apply conditional CSS classes or inline styles in the store locator ISML template. For instance, in the template, one could write:


This method leverages the platform's built-in extensibility without creating redundant data structures. The custom attribute is manageable through Business Manager's "Merchant Tools > Custom Objects" section under Store system object type, allowing business users to toggle the flag per store without developer intervention after initial setup.

Why Other Options Are Incorrect
B. Configure the existing Store custom object type definition – This is misleading because "Store" is a system object, not a custom object type. Custom object type definitions apply to entirely custom data structures, not to extending core platform entities. Modifying system object definitions through custom objects isn't supported for this purpose.

C. Create a new SingleBrandStore custom object configuration – Creating a separate custom object for stores would fragment store data management, requiring duplicate data entry and complex synchronization with the actual Store system objects. It violates data normalization principles and would necessitate complex middleware to link custom object records with actual store entities, increasing maintenance overhead.

D. Adjust the relevant Site Preference in the Stores group – Site Preferences are for global configuration settings, not per-store characteristics. While a preference could control overall behavior, it cannot store individual store distinctions. Using preferences would require hardcoding store IDs or maintaining external lists, which is inefficient and not scalable.

References
Salesforce B2C Commerce Developer Documentation: "Extending System Objects with Custom Attributes"
Business Manager User Guide: "Managing Store Data"
B2C Commerce API Reference: dw.catalog.Store and StoreMgr classes
Best Practices: "Data Modeling in B2C Commerce" – using custom attributes vs. custom objects

A developer is given a task to implement a new Page Designer layout component that doesn’t accept certain asset components.How should the developer achieve the above task?


A. Add component_type_inclusion in the layout json configuration


B. Add component_type_Exclusions in the layout json configuration


C. Add layout_type_inclusion in the target components json configurations.


D. Add layout_type_exclusion in the other asset components json configuration





B.
  Add component_type_Exclusions in the layout json configuration

Explanation:

Why B is correct
Page Designer layout components in SFCC allow fine-grained control over which component types (assets) can be dropped inside them. This is configured directly in the layout component's JSON configuration file (e.g., my-layout.json). The key component_type_exclusions is an array of component type IDs that are explicitly forbidden from being added to this layout. This is the official, recommended way to restrict content types inside specific layouts (introduced and documented since SFRA 3+ / Page Designer 2.x).

Why the other options are incorrect
A. Add component_type_inclusion in the layout json configuration
There is no key called component_type_inclusion in layout configuration. Inclusion is the default behavior — you exclude what you don’t want.

C. Add layout_type_inclusion in the target components json configurations
Components do not control which layouts they can go into. The control direction is layout → allowed/excluded components, not the other way around.

D. Add layout_type_exclusion in the other asset components json configuration
Same conceptual error as C. Asset components should not define layout restrictions — that responsibility belongs to the layout.

References
Salesforce Commerce Cloud Documentation → Page Designer → Component Configuration Schema
Developer Guide: "Restricting Component Usage in Layouts" section

Universal Containers needs to have Apple Pay disabled for the country of Spain.
Which Business Manager module should the Developer use to meet this requirement?


A. Merchant Tools > Ordering > Payment Methods


B. Merchant Tools > Site Preferences > Apple Pay


C. Merchant Tools > Ordering > Payment Processors


D. Merchant Tools > Site Preferences > Payment Types





A.
  Merchant Tools > Ordering > Payment Methods

Explanation:

In Salesforce B2C Commerce, the Payment Methods module is the central hub for managing which payment options (Credit Card, PayPal, Apple Pay, etc.) are available to customers.

When you open a specific Payment Method (like Apple Pay) in this module, you can configure its Country Restrictions. By selecting Spain in the exclusion list or ensuring it isn't in the inclusion list, the platform automatically suppresses Apple Pay as an option for any customer whose basket or session is associated with that country. This is the standard, out-of-the-box way to handle regional payment compliance without writing custom code.

Why the Incorrect Answers are Wrong
B. Merchant Tools > Site Preferences > Apple Pay: While some global Apple Pay settings (like Merchant ID) are found here, the actual enablement, sequencing, and regional availability of the payment option are handled in the Ordering module.

C. Merchant Tools > Ordering > Payment Processors: Payment Processors define the "Engine" (e.g., CyberSource, Adyen) that handles the transaction. While you can associate a method with a processor, the logic of "Do not show this to users in Spain" is a function of the Payment Method configuration, not the Processor itself.

D. Merchant Tools > Site Preferences > Payment Types: "Payment Types" is not a standard module path for managing country-level availability in the B2C Commerce Business Manager.

References
Managing Payment Methods
Apple Pay for B2C Commerce Guide

Universal Containers recently completed updates to their storefront shopping cart page. A problem has been discovered since the update. Users are no longer able to submit coupon codes on this page. Additionally, authenticated userswho try to add a coupon are logged out.
The following processing code is found in the Cart.js controller file:



What should the Developer verify to identify the issue?


A. The CSRF cartridge is included in the site’s cartridge path


B. The form group has the secure attribute set to true


C. The CSRF token is present in the form and is being submitted in the request.


D. The CSRF settings in Business Manager are properly configured.





C.
  The CSRF token is present in the form and is being submitted in the request.

Explanation:

The symptoms described point clearly to a CSRF (Cross-Site Request Forgery) protection failure:

Coupon form fails to submit
Authenticated users are logged out when submitting the form

This is a common result of missing or invalid CSRF tokens. In SFRA (Salesforce Reference Architecture), CSRF protection is enabled by default on forms that use POST, and failure to validate a CSRF token will cause:

Form submission to be rejected
Session to be invalidated (causing logout)

What to Verify:
You should inspect the ISML template that renders the coupon submission form and ensure it includes this hidden input:

This injects the valid CSRF token into the form using the csrf object available in the pipeline dictionary.

Why Other Options Are Incorrect:

A. The CSRF cartridge is included in the site’s cartridge path
➤ CSRF isn’t a standalone cartridge — it’s a middleware provided in SFRA, not a separate cartridge.

B. The form group has the secure attribute set to true
➤ secure="true" ensures the form is submitted via HTTPS, but does not affect CSRF handling.

D. The CSRF settings in Business Manager are properly configured
➤ CSRF settings in BM are rarely the cause — they only define global enforcement, and won’t override missing token logic in your ISML or controller.


Page 2 out of 17 Pages
Previous