Cert++
Close

Business logic placement in ISML templates versus controllers and models

Key Takeaway

Put business logic and web service calls in controllers and models, have the controller add the results to viewData, and let the ISML template only render that data. When a customized route calls a web service, use server.replace instead of server.append so the call doesn't run twice.

In B2C Commerce, an SFRA storefront splits each request across controllers, models, and ISML templates, following the Model-View-Controller (MVC) architecture. Controllers and models prepare data and apply business logic. Templates only render that data as HTML. Some ISML tags are meant for narrow jobs. If you know those jobs, you can spot a template that is doing work that belongs in a controller or model.

Model, view, and controller

B2C Commerce uses the Model-View-Controller (MVC) architecture. Each of the three parts has its own job:

  • The model is the business logic, data, and rules.
  • The view is what the shopper sees, such as the product details page or the cart page.
  • The controller takes shopper input, such as button clicks, and turns it into actions or data that the model or view consumes.
B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given code that violates documented best practices, identify the issues and modify the code to conform with best practices including performance and scalability

0/11

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers.