CCD-102 practice question 14 of 30

A client wants to differentiate their monobrand stores with a special icon when shown in the store locator. The information is saved in a true/false custom attribute for each Store object in Merchant tools. How should the developer follow SFRA best practices to expose this data for rendering?

Full set: 206 questions
Answer options
A: Extend the existing Stores_Find controller with a new middleware function that performs the query
B: Pass the Store system object to the template, so that custom propierties are available
C: Ad dan to the template, and call StoreMgr.searchStoresByCoordinates();
D: Use the module.superModule functionality and the call method to add a new property to the Store Model. Correct answer
Correct Answer:
D. Use the module.superModule functionality and the call method to add a new property to the Store Model.
Explanation

The Storefront Reference Architecture (SFRA) promotes a model-view-controller (MVC) pattern where models are responsible for preparing data as plain JavaScript objects for the view (template). The standard and best practice for adding a custom attribute to the data passed to the template is to extend the relevant base model. By using module.superModule, a developer can inherit the functionality of the base store model, execute its original logic via the call method, and then append the new custom attribute (isMonobrand) to the resulting view model object. This approach maintains separation of concerns and aligns with SFRA's core extensibility principles.

References

1. Salesforce B2C Commerce Developer Documentation

"Extend a Model": This official guide explicitly details the correct pattern for extending a model in SFRA. It states

"To extend a model

you create a file with the same name in your custom cartridge... Get a reference to the base model using the module.superModule property... In the constructor

call the base model constructor... Add or modify properties on the this object." This directly supports option D.

Source: Salesforce B2C Commerce Developer Documentation

"SFRA -> Develop with SFRA -> Customize a Model -> Extend a Model".

2. Salesforce B2C Commerce Developer Documentation

"Storefront Reference Architecture": The documentation on SFRA's architecture emphasizes the use of simple JSON objects (view models) to pass data from controllers to rendering. It states

"The script controller file calls the model to get a simple JSON object...". This principle invalidates option B

which suggests passing complex system objects.

Source: Salesforce B2C Commerce Developer Documentation

"SFRA -> SFRA Concepts -> Models and View Models".

3. Salesforce B2C Commerce Developer Documentation

"Migrate from SiteGenesis to SFRA": This document highlights key differences

noting the move away from tags for business logic. It reinforces that logic should be handled in controllers and models

making option C an outdated and incorrect approach for SFRA.

Source: Salesforce B2C Commerce Developer Documentation

"SFRA -> Migrate from SiteGenesis to SFRA -> Controllers and Routes".

Scroll to Top