Last Updated On : 7-Apr-2026
Salesforce Certified B2C Commerce Cloud Developer - Comm-Dev-101 Practice Test
Prepare with our free Salesforce Certified B2C Commerce Cloud Developer - Comm-Dev-101 sample questions and pass with confidence. Our Salesforce-B2C-Commerce-Cloud-Developer practice test is designed to help you succeed on exam day.
Salesforce 2026
A developerneeds to perform the same additional checks before completing multiple routes
in a custom controller, in orderto decide whether to render a template or redirect the user to
a different page.
According to SFRA best practices, what is the correct approach to improve code reusability
in this scenario?
A. Define a new middleware function and use it in the existing routes.
B. Append a new function to all the existing routes with the server module.
C. Replace the existing routes by creating a controller in separate new cartridge.
D. Use the superModule property in the existing routes to extend their functionality.
Explanation:
According to Salesforce Storefront Reference Architecture (SFRA) best practices, to perform the same additional checks before completing multiple routes in a custom controller and decide whether to render a template or redirect, the developer should A: define a new middleware function and use it in the existing routes. This approach promotes code reusability by centralizing the logic in a reusable middleware, aligning with SFRA’s modular design.
Reasoning:
SFRA Best Practices: SFRA encourages the use of middleware to handle cross-cutting concerns (e.g., authentication, validation) across routes, improving maintainability and reusability.
A. Define a new middleware function and use it in the existing routes.
Correct. The developer can create a middleware function (e.g., in cartridge/scripts/middleware/checkLogic.js) to perform the checks (e.g., user status, conditions) and decide to res.render() or res.redirect(). This middleware is then added to the relevant routes.
Example:
// cartridge/scripts/middleware/checkLogic.js
module.exports = function (req, res, next) {
if (someCondition) {
res.render('template');
} else {
res.redirect('/different-page');
}
next();
};
// cartridge/controllers/Custom.js
var server = require('server');
var checkLogic = require('~/cartridge/scripts/middleware/checkLogic');
server.get('Route1', checkLogic, function (req, res, next) { next(); });
server.get('Route2', checkLogic, function (req, res, next) { next(); });
This avoids code duplication and is easily testable.
B. Append a new function to all the existing routes with the server module.
Incorrect. Appending logic directly to each route duplicates code, violating DRY (Don’t Repeat Yourself) principles. It also doesn’t leverage SFRA’s middleware pattern, making maintenance harder.
C. Replace the existing routes by creating a controller in a separate new cartridge.
Incorrect. Creating a new cartridge to replace routes is overkill and disrupts the existing structure. It doesn’t improve reusability and adds complexity without necessity.
D. Use the superModule property in the existing routes to extend their functionality.
Incorrect. The superModule property is used to extend base cartridge controllers (e.g., from app_storefront_base), not to add reusable checks across multiple custom routes. It’s inappropriate for this scenario.
Implementation Details:
Create Middleware:
In cartridge/scripts/middleware/checkLogic.js:
module.exports = function (req, res, next) {
var user = req.currentCustomer;
if (user.authenticated && user.profile.custom.checkPassed) {
res.render('success', { message: 'Check passed' });
} else {
res.redirect('/login');
}
next();
};
Apply to Routes:
In cartridge/controllers/Custom.js:
var server = require('server');
var checkLogic = require('~/cartridge/scripts/middleware/checkLogic');
server.get('Route1', checkLogic, function (req, res, next) { next(); });
server.get('Route2', checkLogic, function (req, res, next) { next(); });
module.exports = server.exports();
Test: Verify that the middleware correctly renders or redirects based on the checks.
Reference:
Salesforce B2C Commerce Documentation: SFRA Middleware recommends middleware for reusability.
Trailhead Module: “B2C Commerce Developer” module on “Customizing Controllers” covers middleware usage.
Given the requirements:
To show the washing Instructions for a clothing product on a dedicated section the detail
page
Washing instructions come from the product Informationmanager (PIM)
To have this attribute available to localize in the Storefront
Which action must these requirements?
A. Create a custom attribute on the product system object and set it as localizable.
B. Add a resource file for every locale for which the attribute needs to be translated.
C. set the product system object type as localizable.
Explanation:
This question tests understanding of how product data from the Product Information Manager (PIM) is modeled, localized, and rendered in the Salesforce B2C Commerce storefront. It is a classic Comm-Dev-101 exam scenario because it combines three important concepts:
* Product system objects and custom attributes
* Localization of data stored in PIM
* Separation between business data and presentation resources
Understanding the Requirements
The business requirements are very explicit:
* Show washing instructions on the product detail page (PDP)
→ This means the data must be available as part of the product model, not hardcoded in templates.
* Washing instructions come from the Product Information Manager (PIM)
→ PIM data is stored in product system object attributes, not in resource files or templates.
* The attribute must be localizable in the storefront
→ Different locales (e.g., en_US, fr_FR, de_DE) may require different washing instructions.
These requirements clearly indicate that the solution must live at the data model level, not the presentation layer.
Why Option A Is Correct
✅ Creating a Custom Product Attribute
In Salesforce B2C Commerce, product-specific business data (such as washing instructions, materials, care instructions, or ingredients) should always be stored as custom attributes on the Product system object.
This ensures that:
* The data is centrally managed in PIM
* Merchandisers can edit it in Business Manager
* It is accessible via product APIs and templates
✅ Setting the Attribute as Localizable
Marking the custom attribute as localizable allows:
* Different values per locale
* Locale-aware rendering on the storefront
* Proper fallback behavior when a locale-specific value is missing
Once created and localized:
* Merchants can enter washing instructions per locale
* The PDP can display the correct localized value automatically
This approach fully satisfies all three requirements.
Why the Other Options Are Incorrect
❌ Option B: Add a resource file for every locale
Resource files (.properties) are designed for static UI labels, text such as button names, headings, error messages. They are not suitable for PIM-managed product data because:
* Washing instructions are product-specific
* Resource files cannot vary per product
* Managing product content in resource files breaks merchandising workflows
Using resource files would violate Salesforce best practices and make the solution unscalable.
❌ Option C: Set the product system object type as localizable
This option is technically invalid. In Salesforce B2C Commerce:
* Individual attributes can be marked as localizable
* System object types themselves cannot be localized
Localization is always defined at the attribute level, not the object level. Therefore, this option misunderstands how localization works in the platform.
Key Takeaway
Any product-specific, translatable content coming from PIM must be implemented as a localizable custom attribute on the Product system object.
This rule applies not only to washing instructions, but also to:
* Ingredients
* Care instructions
* Legal text
* Country-specific product descriptions
References
Salesforce B2C Commerce Documentation – Product Attributes
Salesforce B2C Commerce Documentation – Localization and Internationalization
Salesforce B2C Commerce Documentation – Product Information Manager (PIM)
In Log Center, a developer notes j number of Cross Site Request Forgery (CSRF) log
entries.
After adding the token in the 15ML template, which action might solve this problem'
A. Add csrfProtection middleware steps in the controller
B. Extend the CSRF token validity to avoidtimeouts.
C. Delete the existing CSRF allow list in Business Manager.
Explanation:
Salesforce B2C Commerce (SFRA) uses a middleware approach to handle security. Adding a CSRF token to an ISML template (via dw.web.CSRFProtection.getToken()) is only the first half of the solution; it places the token in the form. The second half is validation.
The csrfProtection middleware provided by the SFRA server module contains methods such as csrfProtection.validateAjaxRequest or csrfProtection.validateRequest. When these are added to a controller route, the system automatically checks the incoming request’s token against the session. If this middleware is missing, the system may log CSRF errors or fail to validate the legitimacy of the request, which explains the log entries being observed.
Why the Others Are Incorrect
B. Extend the CSRF token validity
CSRF tokens are typically valid for the duration of the session. Extending their validity does not address the core issue, which is that the token is not being validated by the controller at all.
C. Delete the existing CSRF allow list
The CSRF allow list (whitelist) is used to bypass CSRF checks for specific external integrations. Removing it would likely introduce more security errors and does not resolve a missing CSRF validation implementation on a standard storefront route.
References
SFRA Security – CSRF Protection
dw.web.CSRFProtection API
A new product has been added to the Storefront catalog that 15 assigned to a site Which configuration does a developer needto ensure to have a new product visible in the Storefror
A. The search index is built AND the product is online and searchable.
B. The product has a master product AND the search index is built.
C. The product has a price AND the product rs online andsearchable.
Explanation:
Why This Answer Is Correct
For a product to be visible on a B2C Commerce storefront, two non-negotiable, fundamental conditions must be met:
The product must have a price:
A sellable product must be associated with at least one valid price record in the active price book for the site. Without a price, the system considers the product incomplete and unsellable, and it will be excluded from all storefront listings.
The product is online and searchable:
The product’s Online flag must be set to true. This is the master switch that makes a product visible to the storefront. Additionally, the Searchable flag should be set to true. While Searchable primarily affects inclusion in the full-text search index, it is also commonly treated as a prerequisite for a product to be considered active in many catalog queries. Merchants often rely on the Online & Searchable status as the primary control for product visibility.
While building the search index is necessary for products to appear in search results and some listing pages, a product can still appear on its direct URL or through category navigation if it has a price and is online, even if the index is stale. However, the most direct and universally required conditions are having a price and being online.
Why the Other Options Are Incorrect
A. The search index is built AND the product is online and searchable
This is necessary but not sufficient. A product that is online and searchable but has no price will not be visible on the storefront. Even if the search index contains the product, it will be filtered out at render time due to the missing price. The absence of a price is a fatal issue for storefront visibility.
B. The product has a master product AND the search index is built
This is incorrect for multiple reasons. Not all products have a master product—only variants do. Standard products do not. In addition, having a master product does not guarantee visibility. Variants must still be online, have a price, and have an online master product. This option focuses on product structure rather than sellability requirements.
References
B2C Commerce Merchandising Manual: Making Products Available on the Storefront
Catalog Import Guide: Price imports are mandatory for products to be active
A developer working on a multi country site is asked to store country specific data that
drives the creation of a country selector. Examples of the data storedare:
Pricebook to be used
Image URL for country flag
The data used in staging also applies in production, but only for this site.
Which approach should the developer take to implement these requirements?
A. Extend the Locale System Object to contain the custom data for each country.
B. Create a replicable, site-specific Custom Object with the custom data for each country.
C. Create site-specific content assets to store the data for each country.
Explanation:
Why This Answer Is Correct
Custom Objects are the standard way to extend the B2C Commerce data model for specific business logic. By creating a site-specific Custom Object, the developer ensures that the data is partitioned per site. Furthermore, Custom Objects are replicable, meaning data entered in the Staging instance can be pushed to Production via the standard Replication process. This directly matches the requirement that data used in staging also applies in production. Since the requirements include structured fields such as a Pricebook ID and a Flag Image URL for a country selector, a Custom Object provides a clean, type-safe schema to store and retrieve this information efficiently in code.
Why the Other Options Are Incorrect
A. Extend the Locale System Object
While the Locale system object exists, it is not designed to be flexibly extended with custom attributes like image URLs or custom pricebook mappings. System objects have limitations compared to Custom Objects and are not ideal for storing site-specific business configuration data.
C. Create Site-Specific Content Assets
Content assets are intended for managing HTML or text-based content. Although they can technically store JSON or configuration data, this approach is not type-safe and is considered a workaround rather than a best practice. Content assets are also harder to query and maintain when used for structured logic such as mapping countries to pricebook IDs, compared to querying Custom Objects programmatically.
References
Salesforce B2C Commerce – Custom Objects
Replication of Custom Objects
| Salesforce-B2C-Commerce-Cloud-Developer Exam Questions - Home | Previous |
| Page 4 out of 41 Pages |