Salesforce-B2C-Commerce-Cloud-Developer Practice Test
Updated On 1-Jan-2026
202 Questions
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:
To meet these requirements:
Display washing instructions for clothing products on the product detail page
Source the data from the PIM (Product Information Manager)
Ensure the attribute is localizable (translatable by locale)
You need to use a custom attribute on the Product system object that is marked as localizable.
🔹 Step-by-step:
Go to:
Business Manager → Administration → System Object Types → Product
Create a new custom attribute:
e.g., washingInstructions
Type: String or HTML (if formatting needed)
Set "Localizable" = true
Set "Visible on Storefront" = true (optional)
Import localized values from PIM, or manually set per locale.
In your product detail page (product.isml), display the attribute using:
${pdict.Product.custom.washingInstructions}
❌ Why the other options are incorrect:
B. Add a resource file for every locale
❌ Resource files are for UI strings, not product-specific data like washing instructions
C. Set the product system object type as localizable
❌ There’s no setting to make the entire object "localizable" — only individual attributes can be marked localizable
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:
Key Issue:
CSRF log entries indicate missing or invalid CSRF tokens in form submissions.
Adding the token in the ISML template is only half the solution—the backend must also validate it.
Why Option A?
✅ Middleware Validates CSRF Tokens
The csrfProtection middleware validates tokens sent from forms.
Add it to controller routes that handle POST/PUT/DELETE requests:
server.post('SubmitForm', csrfProtection.validateRequest, function (req, res, next) {
// Process form data
});
Fixes the Issue: Ensures tokens are checked server-side.
Why Not Other Options?
❌ B. Extend Token Validity
CSRF tokens expire for security reasons. Extending validity increases risk.
❌ C. Delete CSRF Allow List
The allow list safely exempts trusted endpoints (e.g., APIs). Deleting it forces validation on all routes, which may break valid use cases.
Reference:
SFRA CSRF Protection
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:
For a newly added product to appear on the storefront in Salesforce B2C Commerce (SFCC), the system relies heavily on the search index and product visibility settings.
📌 The two key requirements are:
1. The product must be set to "Online" and "Searchable"
✅ Online: Allows the product to appear on the storefront at all.
✅ Searchable: Allows the product to be indexed and included in search and category listings.
These options are found in Business Manager under:
Merchant Tools → Products and Catalogs → Products → Product Details
2. The search index must be built
SFCC storefront pages (like category grids, search results) are powered by the search index, not real-time database queries.
If the product is added but the index hasn't been rebuilt, the storefront won't display the new product.
Rebuild the index in:
Merchant Tools → Search → Search Indexes
❌ Why the other options are incorrect:
B. "The product has a master product AND the search index is built" ❌
This only applies to variation products.
Not all products need a master; many are standalone products.
Having a master product doesn't guarantee visibility.
C. "The product has a price AND the product is online and searchable" ❌
Having a price is important for the buying flow, but not strictly required for visibility.
Some sites allow products without prices (e.g., “Call for price”).
Missing index build would still prevent the product from showing.
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 Custom Objects Work Best for Multi-Country Selector Data
When building a country selector that needs to store multiple data points per country — such as a pricebook reference, flag image URL, or other configuration values — the most flexible and scalable solution is using Custom Objects.
✅ Option B: Replicable, Site-Specific Custom Object
Custom Object Type: Create a type like CountryConfig
Each object instance holds:
Country code (e.g., US, FR)
Pricebook ID
Flag image URL
Any other relevant metadata
Replicable: Ensures the data is pushed from staging to production
Site-specific: Keeps data confined to one site (important in multi-site realms)
📘 You can access these easily via script or controller logic using:
CustomObjectMgr.getCustomObject('CountryConfig', countryCode);
❌ Why A & C Are Not Suitable
A. Extend the Locale System Object
System Objects like Locale are not customizable, and their scope is global — they can’t store arbitrary key-value data
C. Content Assets
Best for static or visual content, not structured config logic like pricebook mapping — hard to query and maintain programmatically
🔗 Reference:
“Custom Object Types allow developers to create structured, extensible models to store and retrieve configuration data. Replicable and site-specific types ensure deployment flexibility and multi-site isolation.” — Salesforce B2C Commerce Developer Guide
📖 Custom Object Type Documentation
| Salesforce-B2C-Commerce-Cloud-Developer Exam Questions - Home | Previous |
| Page 4 out of 41 Pages |