Cert++
Close

Overriding a base template through the cartridge path

Key Takeaway

To override a base template, give your template the same name and the same relative path as the original, in a cartridge to the left of the original on the cartridge path. B2C Commerce searches from left to right and uses the first match.

In B2C Commerce, you change a base template, such as one in app_storefront_base, without editing the original file. Instead, you add a template with the same name and relative path to your own cartridge. Then you place that cartridge to the left of the base cartridge on the cartridge path. When a template is needed, B2C Commerce searches the cartridge path from left to right and uses the first match, so your version wins.

How the cartridge path finds a file

When a controller, script, model, or ISML template is called through a URL or code, B2C Commerce searches the cartridge path from left to right. B2C Commerce uses the first cartridge that has a file with the same name and the same relative path, which means the same folders inside the cartridge. Because only that first match is used, cartridges to the left override cartridges to the right.

A site uses the cartridge path app-custom-cart-cloudkicks:app_custom_cloudkicks-us:plugin_applepay:plugin_comparison:app_storefront_base. B2C Commerce checks app-custom-cart-cloudkicks first. The base cartridge, app_storefront_base, is checked last. A file in app_custom_cloudkicks-us overrides a file with the same name and relative path in plugin_applepay, plugin_comparison, or app_storefront_base.

The cartridge stack and the cartridge path run in opposite directions. The cartridge stack loads base cartridges first, then plug-in cartridges such as plugin_applepay, and then custom cartridges. The cartridge path does the reverse. Custom cartridges sit on the left, so B2C Commerce finds their files before the base versions.

Only one code version is active at a time. You can upload many cartridges to that code version. Each site's configured cartridge path, including the path for the Business Manager site, decides which cartridge runs.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a development task, code ISML templates that use functionality, such as local include, remote include, components, and other ISML tags

0/14

Prepare for the Exam

Play Today's Certle

Study Community

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