Create a custom cartridge in SFRA (Salesforce Commerce Cloud) using sgmf-scripts
In order to customize SFRA, you will have to install the command-line build tools for SFRA globally. This approach makes it simple to create custom cartridges with the correct structure anywhere on your development machine.
npm install -g sgmf-scripts
After installation, you can use the sgmf-scripts command-line tools in any directory on your machine with a syntax similar to:
sgmf-scripts — help
Storefront Reference Architecture (SFRA) is extensible. You can extend SFRA without editing the app_storefront_base cartridge or other plug-ins. The extensible allows you to take security updates, bug fixes, and adapt to new features easily.
Create Custom Cartridges
Designing a website requires at least one custom cartridge. However, if you intend to create multiple sites, Salesforce suggests creating multiple custom cartridges. Where each cartridge can provide functionality specific to a brand or locale.
Note: You are not supposed to rename the app_storefront_base cartridge or other provided plug-ins. Salesforce suggests keeping the cartridges up to date to receive security updates.
If you installed sgmf-scripts globally just run the following commands to create your first cartridge (In your VS Code open terminal):
- mkdir mycustomsite //creates a folder mycustomsite
- cd mycustomsite //go to the created folder
- npm install sgmf-scripts //install the sgmf-scripts node package
- sgmf-scripts — createCartridge app_sfrademo //create your custom cartridge
- npm install //installs the dependencies
If you haven’t installed sgmf-scripts globally use the following Node.js command instead of the sgmf-scripts createCartridges app_sfrademo command at step 4.
node node_modules/sgmf-scripts — createCartridge app_sfrademo
You can also read about sgmf-scripts package here:
This repository contains a collection of scrips that are useful for creating Storefront Reference Architecture overlay…
Congratulations, you have successfully created your first custom cartridge.