When you need to add new functionality to your storefront site the default approach is to create a new cartridge in your project. The base cartridge, app_storefront_base, has all of the code needed for an SFRA storefront to work in Commerce Cloud Digital. It contains:
There are 2 ways of creating a new cartridge: manually or using the sgmf-scripts node package. During this training, we will show you how to create it manually since it is a very simple process.
There are essentially 2 mandatory files:
Open your app_storefront_base cartridge and check the file named .project. You will see it looks like below:
Create a new folder inside the cartridge folder and name it, for example, app_storefront_custom. Make a copy of the .project you opened inside app_storefront_base and paste it inside your new folder
Your new cartridge needs an identical file, only changing the content of the name tag to the name of your new cartridge.
Same process for the .properties file. Check the one in app_storefront_base, copy to the correct location and replace all app_storefront_base occurrences by the name of your cartridge. At the end, it should look like below.
Whenever you create a new cartridge to add new functionality, it is critical that you respect the same folders' structure that you see in the app_refapp cartridge, otherwise things probably won't work.
When we say path, consider a form field with all cartridges that will be used in the project separated by a colon. Every site has its own path.
Uploading your code to the Sandbox is a mandatory step for your code to work on your storefront but it is not the only one. For a site to use a cartridge, you must add the cartridge to the path of the site in Business Manager.
In order to do that:
There are hundreds of cartridges out there for us to use, so we don't have to reinvent the wheel and very often your project will need some of them.
SFCC has a list of more than 300 cartridges for you to use. To use it:
When a call is made to a file, your sandbox looks for the file starting with the first cartridge listed in the cartridge path. For example, if a call is made to the productDetails.isml file and that file is located in two cartridges that are both in the cartridge path, the first one it finds will be used.
Administrators/developers use WebDAV to manage files and folders on B2C Commerce servers.
Whenever you are unsure if your file or modifications in your file were uploaded to your sandbox, you can use this tool to verify.
Let's use it to make sure all your cartridges are indeed in the sandbox.
Create a new cartridge and make it work. Repeat all the steps and create a new cartridge called app_storefront_base_test