The new requirement is additive: the existingCart-Showbehavior should continue running, and the client cartridge only needs to add adataLayerproperty to the response. SFRA ' s preferred mechanism for this type of extension is toappend middleware to the existing routeand enrich its ViewData.
Salesforce documentsserver.appendas a controller-customization mechanism that executes the existing middleware chain and then adds an additional step. A common use is precisely to retrieve and update the current ViewData with extra properties that are needed during rendering.
This also preserves cartridge independence. Throughmodule.superModule, the client cartridge resolves the applicable controller immediately to its right on the cartridge path. If the LINK cartridge exists, its customized route participates. If it is later removed, resolution can fall through to the next implementation, such asapp_storefront_base, while the client ' s appended data-layer logic remains unchanged.
Replacing the entire route unnecessarily couples the client implementation to existing logic and duplicates behavior that SFRA ' s extension model already provides.
Study Guide reference:Application Development — SFRA controller extension,server.append,module.superModule, ViewData, cartridge precedence, and upgrade-safe customization.
===============
Submit