11 Days of Salesforce Storefront Reference Architecture (SFRA) — Day 1: What Is SFRA?
As Originally published in Medium.com
Photo by Eddi Aguirre on Unsplash
The default show function from the Home controller
If you wanted to extend the action or add new functionality to it — you had to edit the controller itself (usually in the base cartridge). This, as you can probably guess, would cause issues if SFCC updated the controller in a later version — and your changes no longer work.
Another issue you might have had is with using Eclipse. What if you wanted to use your own IDE in an environment you are already familiar? You might be able to find some third party solutions for that — but nothing official from Salesforce themselves.
Fast Forward to SFRA
SFRA is cartridge-based, meaning — everything is essentially a cartridge.
A typical cartridge stack
- The base cartridge is called appstorefrontbase and it hosts the base controllers, modals, scripts etc. that the storefront will need. You should not edit any of its content unless you have a really good reason to. Every SFRA site you create will use this base cartridge for its basic functionality. The base cartridge can be partially configured from Business Manager.
- Plugins are cartridges that are used to enhance commerce capabilities to your site, such as price compare or gift registry. Plugins are usually designed to be a product or feature specific.
- Link cartridges allow you to add third-party functionality to your site and are the main focus of this post series. SFCC has a marketplace of Link cartridges created by partners (shameless plug — the PerimeterX Bot Defender cartridge I developed can be found there as well) which, just like mobile app stores, allow you to extend the functionality of your site.
- Custom cartridges contain specific customization for your site such as product display or search customization. Usually named using the prefix appcustom* for easy distinction of other cartridges.
Controllers and Viewmodels
SFRA uses controllers and viewmodels in order to render a view. The controllers handle data from the user (say a search query) then creates a viewmodel which requests the data from SFCC in theform of pure JSON and passes that info forward to render the page/template.
yap, I’m not a designer by any means
This pattern is very similar to the Model-View-Controller pattern and you can read up some more about on Wikipedia.
A Word About OnRequest and OnSession
If you are coming from SGJC, you should be aware that OnRequest and OnSession event handlers that were supported in SGJC are not (directly) used in SFRA. We will go into more details about this change in a future post, but in short, SFRA will only support onSession and onRequest as a hook, which means it won't have access to the request and response objects.
Now that you have a general idea of what SFRA is, check out the remaining 10 days:
- Day 2: Setting up Your Development Environment
- Day 3: Creating a Storefront
- Day 4: Creating a Basic Cartridge
- Day 5: Using Custom Preferences
- Day 6: Using Services Framework
- Day 7: More Services Framework
- Day 8: A Tale of Two Events
- Day 9: Jobs
- Day 10: Advanced Jobs
- Day 11: Playing with Templates
As always, looking forward to your comments either here or on Twitter 😎