Working with Controllers

If you are starting a new storefront implementation, Salesforce recommends using controllers instead of pipelines for your application code.

What are Controllers?

Controllers are server-side scripts that handle storefront requests. Controllers manage the flow of control in your application, and create instances of models and views to process each storefront request and generate an appropriate response. For example, clicking a category menu item or entering a search term triggers a controller that renders a page.

Controllers are written in JavaScript and Salesforce B2C Commerce script. They must conform to the CommonJS module standard (see Using B2C Commerce Script Modules).

Types of Controllers

Commerce Cloud offers two types of controllers: SFRA and SGJC. These different types cannot be mixed and matched within a single cartridge.

Note: If you are starting a new project, we recommend that you use SFRA. For a brief discussion of SFRA benefits, see Commerce Cloud Reference Applications.

See Also

For information about SFRA controllers, see SFRA Controllers and Customizing SFRA Controllers and Routes.

For information about SGJC controllers, see SiteGenesis Modules and Hooks and Using B2C Commerce Script Modules

For information about the differences between pipelines and SGJC controllers, see Comparing Pipelines and SGJC Controllers.