<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abha on Medium]]></title>
        <description><![CDATA[Stories by Abha on Medium]]></description>
        <link>https://medium.com/@abhan95?source=rss-293113d2358f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2Pc2RQ2t9XYHGjWj</url>
            <title>Stories by Abha on Medium</title>
            <link>https://medium.com/@abhan95?source=rss-293113d2358f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 12:55:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhan95/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Points to Remember while customizing SFRA Controllers and Routes]]></title>
            <link>https://abhan95.medium.com/points-to-remember-while-customizing-sfra-controllers-and-routes-354539d83317?source=rss-293113d2358f------2</link>
            <guid isPermaLink="false">https://medium.com/p/354539d83317</guid>
            <category><![CDATA[salesforce-developer]]></category>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[sfcc]]></category>
            <category><![CDATA[salesforce-development]]></category>
            <category><![CDATA[demandware]]></category>
            <dc:creator><![CDATA[Abha]]></dc:creator>
            <pubDate>Tue, 13 Oct 2020 11:01:50 GMT</pubDate>
            <atom:updated>2020-12-18T11:12:04.096Z</atom:updated>
            <content:encoded><![CDATA[<h3>Points to Remember while customizing Storefront Reference Architecture (SFRA) Controllers and Routes</h3><p>The Salesforce Commerce Cloud’s Storefront Reference Architecture provides best practices for building a storefront site. While working on your own storefront site, you can use SFRA as your base and can customize the existing controllers and routes to meet individual merchant requirements.</p><p>Keep the following points in mind-</p><h4>1. While <strong>Overriding any controller</strong>/module-</h4><p><em>WHEN</em>- If you want to avoid executing the middleware of the controller or script you’re modifying.</p><p><em>HOW</em>- Use the module.superModule mechanism to import the functionality from a controller and then override or add to it.</p><h4>2. While <strong>Extending any controller</strong>/module-</h4><p><em>WHEN</em>-If the middleware you want to override is looking up a string or performing inexpensive operations, you can extend the controller or module.</p><p><em>HOW</em>- Use the module.superModule mechanism to import the functionality from a controller and then override or add to it.</p><p>In case of extending, note-</p><p>a. When extending a controller, you first execute the original middleware and then execute the additional steps included in your extension.</p><p>b.If the original middleware steps include interaction with a third-party system, that interaction is still executed.</p><p>c.If your extension also includes the interaction, the interaction is executed twice.</p><p>d. Similarly, if the original middleware includes one or more steps that are computationally expensive, you can avoid executing the original middleware.</p><p><strong>Example-</strong></p><p>This example customizes the product detail page to include product review information.</p><pre>// Product.js<br><br>&#39;use strict&#39;;<br><br>var server = require(&#39;server&#39;);          //<strong><em>require server module</em></strong><br>var page = module.superModule;           //<strong><em>inherits functionality from next Product.js found to the right on the cartridge path</em></strong></pre><pre>server.extend(page);                     //<strong><em>extends existing server      object with a list of new routes from the Product.js found by module.superModule</em></strong></pre><pre>//<strong><em>Modifies the </em></strong><strong><em>Show route by appending middleware that adds properties to the </em></strong><strong><em>viewData object for rendering.</em></strong><br>server.append(&#39;Show&#39;, function (req, res, next) {<br> <br> var viewData = res.getViewData();    //<strong><em>Gets the current </em></strong><strong><em>viewData    object from the response object.</em></strong></pre><pre>viewData.product.reviews = [{<br>        text: &#39;Lorem ipsum dolor sit amet, cibo utroque ne vis, has no sumo graece.&#39;,<br>        rating: 3.5<br>    }, {<br>        text: &#39;Very short review&#39;,<br>        rating: 5<br>    }, {<br>        text: &#39;Lorem ipsum dolor sit amet, cibo utroque ne vis, has no sumo graece.&#39;,<br>        rating: 1.5<br>    }];<br><br>    res.setViewData(viewData);    //<strong><em>Updates the </em></strong><strong><em>viewData object used for rendering the template.</em></strong><br>    next();<br>});<br><br>module.exports = server.exports();</pre><p>Note-</p><p>a. server.append causes a route to execute both the original middleware chain and any additional steps. If you&#39;re interacting with a web service or third-party system, don’t use server.append.</p><p>b. In case of server.setViewData, create your customized template in the same location and with the same name as the template rendered by the superModule controller.</p><h4>3. While <strong>Replacing any controller</strong>/module-</h4><p><em>WHEN</em>-It is recommended to replace a route to change individual steps in a middleware chain.</p><p><em>HOW</em>-Use module.superModule to inherit the functionality of the controller and route you want to replace. Then register the functions you want the route to use.</p><p>You can’t change a step in the middleware chain. However, you can either replace the whole route or append a new step after the chain completes, but before the template renders. Usually, if you’re appending a step, it’s to override or add data to the ViewData object.</p><h4>4. While Customizing a Controller with a Web Service or a Call to a Third Party</h4><p>a.In general, customizing a controller with a web service or third-party call uses the same mechanisms as other types of customizations.</p><p>b. Make sure that you don’t execute the controller twice. Executing the controller twice is possible if you use server.append to customize the ViewData object passed to the rendering template. Instead, simply replace the route entirely.</p><p>For more details, read the documentation and trailhead modules :</p><ol><li><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fsfra%2Fb2c_sfra_modules.html&amp;cp=0_6_3_0_3">https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fsfra%2Fb2c_sfra_modules.html&amp;cp=0_6_3_0_3</a></li><li><a href="https://trailhead.salesforce.com/en/content/learn/modules/b2c-implement-functional-solution/b2c-customize-store-with-ref-architecture">https://trailhead.salesforce.com/en/content/learn/modules/b2c-implement-functional-solution/b2c-customize-store-with-ref-architecture</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=354539d83317" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>