<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sfcc Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/tag/sfcc/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/tag/sfcc/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Mon, 05 Feb 2024 14:01:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Dreamforce 2023 Highlights</title>
		<link>https://blogit.create.pt/davidpereira/2024/02/05/dreamforce-2023-highlights/</link>
					<comments>https://blogit.create.pt/davidpereira/2024/02/05/dreamforce-2023-highlights/#respond</comments>
		
		<dc:creator><![CDATA[David Pereira]]></dc:creator>
		<pubDate>Mon, 05 Feb 2024 14:01:48 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[sfcc]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=13007</guid>

					<description><![CDATA[<p>In this post I&#8217;ll go over my highlights of a huge event that took part some months ago &#8211; Salesforce Dreamforce 2023. Many announcements are interesting like Marketing Cloud and Commerce Cloud being integrated into the Einstein 1 platform. I believe for Commerce Cloud this means only the B2B and D2C products… at least for [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2024/02/05/dreamforce-2023-highlights/">Dreamforce 2023 Highlights</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this post I&#8217;ll go over my highlights of a huge event that took part some months ago &#8211; Salesforce Dreamforce 2023. Many announcements are interesting like Marketing Cloud and Commerce Cloud being integrated into the Einstein 1 platform. I believe for Commerce Cloud this means only the B2B and D2C products… at least for now 🙂. I&#8217;ll focus on the B2C side of Commerce Cloud, although most features were announced for B2B and D2C.</p>



<p>You can also watch <a href="https://www.youtube.com/watch?v=4j-HyuHDQQ4">Salesforce Keynote highlights of the event</a>.</p>



<h2 class="wp-block-heading">Einstein 1 Platform</h2>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" width="708" height="362" src="https://blogit.create.pt/wp-content/uploads/2024/02/einsteinplatform.webp" alt="einstein 1 platform slide" class="wp-image-13080" style="width:708px;height:auto" srcset="https://blogit.create.pt/wp-content/uploads/2024/02/einsteinplatform.webp 708w, https://blogit.create.pt/wp-content/uploads/2024/02/einsteinplatform-300x153.webp 300w, https://blogit.create.pt/wp-content/uploads/2024/02/einsteinplatform-696x356.webp 696w" sizes="(max-width: 708px) 100vw, 708px" /><figcaption class="wp-element-caption">Image source &#8211; <a href="https://www.youtube.com/watch?v=Ew-xxNhhscU&amp;t=1528s">Dreamforce 2023 Main Keynote</a></figcaption></figure>
</div>


<p>Salesforce announced the&nbsp;<strong>Einstein Trust Layer</strong>&nbsp;which seems to be their focus of what&#8217;s behind the Einstein 1 Platform. This makes sense since Salesforce&#8217;s core value is <strong>trust</strong>, this product might be&nbsp;the core that separates Salesforce AI functionality from other solutions. I&#8217;m very interested in learning more about each specific part they announced, like data masking, zero retention, and dynamic grounding. We should know what prompt is sent to the LLMs, how the <strong>CRM and other enterprise data</strong> are used in prompts (for dynamic grounding), and <strong>how exactly</strong> zero retention is implemented in each LLM provider (e.g. OpenAI). It&#8217;s great seeing a slide explaining Einstein Trust Layer makes sure the prompt is not used by the LLMs to train their model, but I think it&#8217;s important to challenge these claims and ask questions 🙂.</p>



<p>It would also be interesting to try and connect external models or cloud services, like LAMA, Amazon SageMaker or Azure OpenAI service. This way we take advantage of the middleware inside the Trust Layer that guarantees security and input moderation. As partners, we have access to some Salesforce events and I definitely recommend attending &#8220;<strong>AI &amp; Einstein Office Hours</strong>&#8221; on Tuesdays. Claudio Moraes from Salesforce is sharing extremely useful information about Einstein GPT, the details of the Trust Layer, and more AI topics!</p>



<p>Here are some interesting videos that Salesforce has already done, explaining further the Einstein Trust layer and Einstein GPT:</p>



<ul class="wp-block-list">
<li><a href="https://www.youtube.com/watch?v=6KdUfqQ1szE">Build The Future of Business with Einstein GPT  </a></li>



<li><a href="https://www.youtube.com/watch?v=JuYwz5qkSbk">Salesforce AI day: Calling All Trailblazers</a></li>
</ul>



<p></p>



<h2 class="wp-block-heading">Einstein Copilot</h2>



<p>Well… as you know, 2023 was the year of copilots. Salesforce is also taking advantage of that wave and has <a href="https://www.salesforce.com/news/press-releases/2023/09/12/ai-einstein-news-dreamforce/">introduced Einstein Copilot and Einstein Copilot Studio</a>. This looks a lot like what they announced some time ago, Einstein GPT.</p>



<p>I think it&#8217;s great that Einstein is more integrated across various products, especially Commerce and Service Cloud. Facilitating the manual work that the business has to do in various merchandising operations only brings benefits.</p>



<p></p>



<h2 class="wp-block-heading">Generative AI in SFCC Page Designer</h2>



<p>About <a href="https://www.salesforce.com/plus/experience/Dreamforce_2023/series/commerce_at_dreamforce_2023/episode/episode-s1e3">generative Page Designer that they announced</a>, we could simply say &#8220;yup, LGTM&#8221; and simply use it… but I do have some questions that need answering 😅. The demo they showed looks good and it&#8217;s probably a feature that brings tons of value to a lot of customers. But watching it made my mind go through endless questions. At first glance it&#8217;s amazing, we could really speed up the development of new components. UI/UX designers, merchandisers, and other business profiles can ask an AI to generate a component without a dev.</p>



<p>Still, I think as a developer we need to understand what is happening underneath, where is the generated code saved, what is the prompt used to generate the component, does it have context of the whole codebase, etc. This might have been the most interesting announcement and something to watch out for. However, we must also criticize and understand the limitations of this technology. In the demo they created, the user enters a brief description of the layout and content they want in the component, then the code is generated in React (it also supports ISML). I don&#8217;t believe React is actually used in SFRA, only in the Headless architecture, so their demo raises some questions about how it works underneath.</p>



<p>But anyway, I look at this as if it were <a href="https://v0.dev/">v0.dev</a>, that is, the <strong>1st version or v0 of a component</strong>. The business or UI designers can experiment and generate several iterations of a component with this functionality, and then paste the generated code into a user story in a scrum board for a developer to retrieve. But it would just be a v0, something to be iterated over before going to production. I don&#8217;t think we&#8217;re ready yet for generative AI to know the website&#8217;s design system, know what caching considerations to apply to the component, have context about the logic behind add to cart if it&#8217;s integrated with a 3rd party vendor, etc. But we could also be optimistic and in all the use cases where gen AI struggles, it&#8217;s only going to improve.</p>



<p><strong>Note</strong>: Page Designer&#8217;s Generative AI is expected to launch in beta in February 2024.</p>



<p></p>



<h2 class="wp-block-heading">Commerce Concierge</h2>



<p>Salesforce also announced a new product that is in beta called Commerce Concierge. Basically, the product is centered on the concept of Conversational Commerce. We can integrate our e-commerce website into WhatsApp as if it were one of those ChatGPT plugins that allow you to make purchases on a website.</p>



<p>For example, a customer takes a photo of a product and asks if there is a store with stock so they can make the purchase. If the customer happens to make a purchase on WhatsApp, the bot can respond with new product suggestions trying to effectively cross-sell. Technically, Commerce Concierge uses APIs from Commerce Cloud, Service Cloud, Data Cloud, and the AI ​​layer with Einstein GPT. At the moment I think it will only be launched for Commerce B2B and not B2C. This makes sense to me since it is easier to integrate Clouds that are already within the Salesforce Core Platform&#8230; but I hope we have this for SFCC in the future 🙂. I also think it will be possible to expand to more touchpoints, not just WhatsApp.</p>



<p>It&#8217;s also important to be aware of new attack vectors. Innovation is awesome and we should strive for more and tinker with these new capabilities. However, innovation can bring new security concerns. In these apps that will be available straight from WhatsApp or our storefront, we should be aware of <a href="https://learnprompting.org/docs/prompt_hacking/injection">Prompt injection</a>, <a href="https://learnprompting.org/docs/prompt_hacking/jailbreaking">Jailbreaking</a>, etc.</p>



<p></p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>It was a great event and I can&#8217;t wait to get my hands on some Einstein GPT features for B2C! Hopefully, there will be more features on SFCC that are only available for customers of B2B and D2C 🙏. For example generating product descriptions or commerce intelligence 🙂.</p>



<p>Generating product descriptions with Einstein seems to be really useful if we have a batch of new products that we want to launch. It would be great to have this available in an HTTP API, so that we could integrate this functionality in use cases where our PIM (Product Information Management) is a custom system, or just use them in SFCC. Again&#8230; for now some features are only on B2B and D2C side of the commerce products (the ones integrated in Salesforce Core Platform).</p>



<p>If you&#8217;re interested in learning about session management in SFCC <a href="https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/">read this blog post</a>.</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2024/02/05/dreamforce-2023-highlights/">Dreamforce 2023 Highlights</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/davidpereira/2024/02/05/dreamforce-2023-highlights/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to use SEO meta tag rules for Page Designer in SFCC</title>
		<link>https://blogit.create.pt/davidpereira/2022/09/07/seo-meta-tag-rules-sfcc-page-designer/</link>
					<comments>https://blogit.create.pt/davidpereira/2022/09/07/seo-meta-tag-rules-sfcc-page-designer/#respond</comments>
		
		<dc:creator><![CDATA[David Pereira]]></dc:creator>
		<pubDate>Wed, 07 Sep 2022 17:18:48 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[sfcc]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12745</guid>

					<description><![CDATA[<p>SEO meta tag rules module in SFCC can be customized to support all page designer pages! Learn how in this blog post.</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2022/09/07/seo-meta-tag-rules-sfcc-page-designer/">How to use SEO meta tag rules for Page Designer in SFCC</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>We have a great feature available to us in Salesforce Commerce Cloud (SFCC) called <a href="https://trailhead.salesforce.com/en/content/learn/modules/b2c-seo-meta-tags/b2c-seo-meta-tag-explore-rules" target="_blank" rel="noreferrer noopener">SEO meta tag rules</a>. This is a module inside SEO in Business Manager (BM). However, currently there is <strong>only support for <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/page_designer/b2c_use_page_meta_tag_rules_for_pd.html" target="_blank" rel="noreferrer noopener">PDP/PLP pages made in page designer</a></strong> that support these meta tag rules.</p>



<p>In this blog post we&#8217;ll see how to support SEO meta tag rules for <strong>all pages made in page designer</strong>.</p>



<h2 class="wp-block-heading">The problem</h2>



<p>Before going any further, I want to mention some disclaimers. At the time of writing this, not all pages in page designer support this. This could be added to SFCC and be directly supported without custom development. I posted this idea as a <a href="https://ideas.salesforce.com/s/idea/a0B8W00000JJF4rUAH/support-all-page-designer-pages-for-seo-meta-tag-rules" target="_blank" rel="noreferrer noopener">feature enhancement for Salesforce in IdeaExchange</a>.</p>



<p>With that said, let&#8217;s take a step back and understand the problem.</p>



<p>The SEO experts on a business operate mostly on the SEO meta tag rules BM module. If they need a more granular level of SEO customization, most System Objects (e.g. Products, Content Assets, Categories) of SFCC support SEO fields like <code>pageUrl</code>,<em> </em><code>pageTitle</code>, <code>pageDescription</code>. SEO experts can define rules that act as fallbacks, and then if some merchants don&#8217;t define these fields for particular categories or pieces of content. You still have some meta tags being added to the page by these rules.</p>



<p>Now, even though this feature supports many types of pages, like home page, product pages or product listing pages. It doesn&#8217;t support all types of Page Designer (PD) pages. You can also take a look at the <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FDWAPI%2Fscriptapi%2Fhtml%2Fapi%2Fclass_dw_experience_Page.html" target="_blank" rel="noreferrer noopener">Page class</a>, and check that it doesn&#8217;t have the <code>pageMetaTags</code> field like the <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FDWAPI%2Fscriptapi%2Fhtml%2Fapi%2Fclass_dw_content_Content.html" target="_blank" rel="noreferrer noopener">Content class</a> does. Page Designer pages are very similar to Content Assets, in the sense that underneath, <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC2/topic/com.demandware.dochelp/content/b2c_commerce/topics/page_designer/b2c_pg_comp_types_content_assets.html" target="_blank" rel="noreferrer noopener">these pages are persisted as the same content objects on the SFCC&#8217;s database</a>. But there are still differences, the support for meta tag rules is one of them.</p>



<p>Ultimately, these differences makes it harder for merchants or SEO experts that want to leverage the same functionality available on the rest of the site.</p>



<p>Now that you have a better understanding about the problem, let&#8217;s shift our focus into a solution.</p>



<h2 class="wp-block-heading">The solution</h2>



<p></p>



<h3 class="wp-block-heading">Content Assets</h3>



<p>The whole premise of this solution is that it&#8217;s supported by the SEO meta tag rules module of BM. In this module we have support for the following:</p>



<ul class="has-regular-font-size wp-block-list">
<li>Homepage</li>



<li>Product pages</li>



<li>Content Detail pages</li>



<li>Content Listing pages</li>
</ul>



<p>The only one that fits well with a page designer page is <strong>Content Detail page</strong>. Meaning we&#8217;ll create content assets as a way to support these SEO rules for Page Designer. Each page can have it&#8217;s corresponding content asset, where the content ID follows a naming convention like &#8220;-seo&#8221;. This way in <code>Page.js</code> you can get the meta tags for that page, through that content asset. Here is an example of the <code>Page-Show</code> extension:</p>



<pre class="wp-block-code"><code>server.prepend("Show", function (req, res, next) {
   var PageMgr = require('dw/experience/PageMgr')
   var ContentModel = require('*/cartridge/models/content')
   var pageMetaHelper = require("*/cartridge/scripts/helpers/pageMetaHelper")

    var page = PageMgr.getPage(req.querystring.cid);
    if (page != null &amp;&amp; page.isVisible()) {
        var pageContent = ContentMgr.getContent(page.ID + "-seo")
        if (pageContent) {
            var content = new ContentModel(pageContent, "content/content")

            pageMetaHelper.setPageMetaData(req.pageMetaData, content)
            pageMetaHelper.setPageMetaTags(req.pageMetaData, content)
        }
    }
    next()
})</code></pre>



<p>Now you don&#8217;t need to create a content asset for every since page from PD. For example, if you business doesn&#8217;t use the syntax <code>${Content.pageTitle}</code> in your meta tag rules, or any expression regarding the object <code>Content</code>. Then in that case you could simply create one content asset for each folder the business wants to have. You might be wondering why I&#8217;m mentioning folders and how they fit in the solution, so let&#8217;s take a deeper look.</p>



<p></p>



<h3 class="wp-block-heading">Folders</h3>



<p>Folders are the way you can group multiple pages, and make all of them inherit the same meta tag rules. Once a folder is created, the business can use it in the SEO meta tag rules module inside BM. Imagine you have a group of pages that are part of the same marketing campaign. As an SEO expert, of course you&#8217;d like to have page titles, descriptions, open graph and other meta tags for all of them. But maybe the content team hasn&#8217;t reached the maturity level to configure this for every since page. So you create a meta tag rule, acting as a fallback in case the content team doesn&#8217;t configure some pages.</p>



<p></p>



<p>So far the solution revolves around the business creating manually: folders, assigning them to pages and creating content assets for every page (in case they want to leverage page properties) or every folder. I believe we can improve on this solution, so let&#8217;s jump in to some automation!</p>



<h3 class="wp-block-heading">Automation</h3>



<p>This is a critical step, since having all this manual work doesn&#8217;t make sense for business people. As engineers we can do better and automate the creation of these content assets. We can develop two different pieces that play together:</p>



<ul class="wp-block-list">
<li>A <strong>job</strong> to ensure every page from Page Designer, has it&#8217;s associated content asset and all the rest</li>



<li>A <strong>new BM module</strong> to automate folder creation, specifically creating multiple folders</li>
</ul>



<p>Let&#8217;s go through the job first, its responsible to update the content assets associated with each page. This means creating that content asset if it doesn&#8217;t already exist, then assign it to the same folders as the page. To implement this job you need:</p>



<ol class="wp-block-list">
<li>Get the list of all Page Designer pages</li>



<li>Iterate through all pages</li>



<li>For each page, create the content asset and assign the appropriate folders</li>
</ol>



<p>Here is a code snippet (in ES6) representing a possible implementation:</p>



<pre class="wp-block-code"><code>const libraryGateway = require("*/cartridge/scripts/gateways/libraryGateway")
const pagesList = getAllPageDesignerPages()

pagesList.forEach(page =&gt; {
    const contentId = `${page.ID}-seo`
    const result = libraryGateway.createContentAsset({
        id: contentId,
        pageTitle: page.pageTitle
    })
    if (result.error) {
        throw new Error("Error creating content asset")
    }
    
    page.folders.forEach(folder =&gt; {
        const result = libraryGateway.assignContentAssetToFolder(contentId, folder.ID)
    })
})

function getAllPageDesignerPages() {
    const ContentSearchModel = require("dw/content/ContentSearchModel")
    const apiContentSearchModel = new ContentSearchModel()
    const libraryID = "someId"
    
    apiContentSearchModel.setRecursiveFolderSearch(true)
    apiContentSearchModel.setFilteredByFolder(false)
    apiContentSearchModel.setFolderID(libraryID)
    
    apiContentSearchModel.search()
    const contentSearchResultIterator = apiContentSearchModel.getContent()
    const count = Number(apiContentSearchModel.getCount())
    
    const pages = &#91;]
    if (contentSearchResultIterator &amp;&amp; count &gt; 0) {
        while (contentSearchResultIterator.hasNext()) {
            const contentResult = contentSearchResultIterator.next()
            if (contentResult?.page) {
                // transform some contentResult fields to other types...
                pages.push(contentResult)
            }
        }
    }
    
    return pages
}</code></pre>



<p>In the implementation above, getting all pages from page designer is done through the <code>ContentSearchModel</code> API. Although this works, it&#8217;s not ideal in my opinion since these pages are required to be <strong>searchable</strong> (a setting on all pages) and <strong>online</strong>. If they aren&#8217;t, they won&#8217;t be on the <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC2/topic/com.demandware.dochelp/content/b2c_commerce/topics/search_and_navigation/b2c_index_creation.html">Content index</a>. Which seems to be the only way to get all PD pages on the site. To create content assets and assigning them to folders, we delegate that responsibility to the <code>libraryGateway</code> module. To implement this module we need to use OCAPI.</p>



<h3 class="wp-block-heading">OCAPI</h3>



<p>We can use OCAPI Data APIs to create content assets/folders and assign content assets to folders. While researching I tried finding another way, but I didn&#8217;t find anything easier. The <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/DWAPI/scriptapi/html/api/packageList.html?cp=0_20_2">Salesforce Commerce API</a> (<em>dw</em> library accessible server-side) doesn&#8217;t seem to have APIs for these operations. I didn&#8217;t find any pipelets or jobs steps that do this either… perhaps by <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/DWAPI/jobstepapi/html/api/jobstep.ExportContent.html">exporting the content library</a>, then creating a custom job that reads that file, edits it with the new content objects, and finally runs a job step to import that edited file.</p>



<p>Interacting with OCAPI is not an expensive development effort, so you can develop a custom cartridge for this. We won&#8217;t go through the details about that cartridge, perhaps on a separate blog post.</p>



<h3 class="wp-block-heading">OCAPI endpoints</h3>



<p>All the operations we want to do can be found on the Libraries resource from the Data API. To create a content asset we can use <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FOCAPI%2Fcurrent%2Fdata%2FResources%2FLibraries.html&amp;anchor=id893141162__id696504113" target="_blank" rel="noreferrer noopener">this endpoint</a>, to assign it to a folder we can use <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FOCAPI%2Fcurrent%2Fdata%2FResources%2FLibraries.html&amp;anchor=id893141162__id-2058222274" target="_blank" rel="noreferrer noopener">this endpoint</a>. One thing to keep in mind, creating a content asset is an <strong>idempotent </strong>operation. This means it creates the object if it doesn&#8217;t already exist, but if it does it ignores the existing object and writes a new one on top.</p>



<p>In practice, this means if someone edits these content assets (e.g. through BM, locking the resource and updating the description field), that modification will be lost. If you don&#8217;t want to lose those edits, you should consider using the endpoint to get the content asset, and use that data on your PUT request payload. In my case, these content assets are supposed to be &#8220;hidden&#8221;, so no one should need to edit them.</p>



<h3 class="wp-block-heading">BM extension to create folders</h3>



<p>Now let&#8217;s discuss the custom BM module to create folders. If business people want to create multiple filters in one go, instead of doing it through the BM UI and then going to Page Designer to assign pages to folders, they input the filter names in an input box and click a button. We can simply develop a web page that has this input box and a button (and some instructions on how to use it). This is possible by <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/site_development/b2c_customize_business_manager.html">extending BM</a> and building a custom cartridge, with this UI and the controller that executes the creation of folders. We won&#8217;t go to much into detail about this custom cartridge, I&#8217;ve added additional links at the bottom to help you building this cartridge.</p>



<h3 class="wp-block-heading">Alternative solutions to SEO meta tag rules</h3>



<p>In the case where the content object quotas are hit, we can consider building something entirely custom. What I mean is we would not use the SEO meta tag rules module from BM anymore. We would build our piece of software to handle this scenario &#8211; <strong>all page designer page types</strong>. Of course that means building software that does the same as Salesforce&#8217;s built-in module of BM, considering: Storage to store these rules, meta tag definitions, and others; an API that at least exposes a way to get meta tags for a given page, taking into account API design, SLA (important if you&#8217;ll call this in a middleware of the Page.js controller), etc.</p>



<p>This is a discussion you must have with your business/client, explaining the trade-offs of each scenario.</p>



<p>In my opinion, it&#8217;s generally often better to reuse existing functionality or an off-the-shelf solution like a plugin cartridge. Something that either is standardized and known in the community, instead of your own solution… but as always, this depends on the context we&#8217;re in. For SEO meta tag rules of SFCC in particular, we <a href="https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000Hk216SAB">can&#8217;t extend this module</a>. So if we really needed to support this feature and we hit the API quotas of the SFCC platform, we would consider building a cost-effective solution outside SFCC, considering the need of a custom parser for <code>if</code> statements, context variables… again a discussion to be made with the business and architects.</p>



<h3 class="wp-block-heading">Improvements to this solution</h3>



<p>One important note about this solution is that pages would <strong>only inherit meta tags assigned to the default folder</strong> (primary folder). From my research, a content asset can only have one default folder, and that is the folder the meta tags come from. In my use case the ideal was to setup some hierarchy, where a page could have 3 folders, and you could get all meta tags assigned to those folders. Now you kind of have this <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/search_engine_optimization/b2c_meta_tag_rules.html">hierarchy</a> (primary folder, then parent folders, up to root), but it&#8217;s not the exact behavior I needed.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>In conclusion, you can develop a custom cartridge with this functionality, and support this for your business or clients. In the future, this could be supported out of the box by SFCC. The greatest challenges were: analyzing ways to extend the SEO meta tag rules module; an API to get all page designer pages and understanding the limitations of our solution. Let us know in the comments if this feature is something you&#8217;d like to have, or vote and comment on the <a href="https://ideas.salesforce.com/s/idea/a0B8W00000JJF4rUAH/support-all-page-designer-pages-for-seo-meta-tag-rules">IdeaExchange&#8217;s post</a>. I hope this has been helpful.</p>



<p>Check out my other blog post on <a href="https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/" target="_blank" rel="noreferrer noopener">session management for SFCC</a>.</p>



<h2 class="wp-block-heading">Additional links</h2>



<p>Here are some links to documentation and other resources, that can help you in building this feature for your business: </p>



<ul class="wp-block-list">
<li><a href="https://ideas.salesforce.com/s/idea/a0B8W00000JJF4rUAH/support-all-page-designer-pages-for-seo-meta-tag-rules">IdeaExchange&#8217;s post</a></li>



<li><a href="https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000IRNXRSA5">How to get a list of pages of Page Designer using code?</a></li>



<li><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/OCAPI/current/data/Resources/Libraries.html">OCAPI Data Libraries resource</a></li>



<li><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/admin/b2c_configuring_a_business_manager_site.html">Configuring the Business Manager Site</a></li>
</ul>
<p>The post <a href="https://blogit.create.pt/davidpereira/2022/09/07/seo-meta-tag-rules-sfcc-page-designer/">How to use SEO meta tag rules for Page Designer in SFCC</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/davidpereira/2022/09/07/seo-meta-tag-rules-sfcc-page-designer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Session management in Salesforce B2C Commerce Cloud</title>
		<link>https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/</link>
					<comments>https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/#comments</comments>
		
		<dc:creator><![CDATA[David Pereira]]></dc:creator>
		<pubDate>Mon, 06 Jun 2022 10:16:14 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[sfcc]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12711</guid>

					<description><![CDATA[<p>A look into how session management works in Commerce Cloud, from a real use case.</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/">Session management in Salesforce B2C Commerce Cloud</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>Recently, I had a challenge in our production system that was a bit annoying to figure out how to solve. Who knew that code can be deployed on a production environment and not work, even though it works on all other environments&#8230;</p>



<p></p>



<p>I did some digging and asked in forums what was the difference between session management on different environments on Salesforce Commerce Cloud (SFCC). Unfortunately I didn&#8217;t find anything, only <a href="https://help.salesforce.com/s/articleView?language=en_US&amp;type=1&amp;id=000359741" target="_blank" rel="noreferrer noopener">limits and good practices</a> that didn&#8217;t help in this case.</p>



<p>Well that&#8217;s life right? What do you do?? You decide to be pragmatic because a feature that works and is on the hands of real people, is far better than dreams of a perfect world.</p>



<h2 class="wp-block-heading">The session problem</h2>



<p>All you know is that attributes that you are saving on the <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FDWAPI%2Fscriptapi%2Fhtml%2Fapi%2Fclass_dw_system_Session.html" target="_blank" rel="noreferrer noopener">SFCC platform&#8217;s session object</a>, are not available where you need them. For the sake of this example, let&#8217;s say we are talking about a flow between the SFCC site and an API.</p>



<p>The code at the moment is something like this:</p>



<pre class="wp-block-code"><code>// apiGateway.js script
const apiResponse = { data: "something" };
session.privacy.myCustomField = JSON.stringify(apiResponse);</code></pre>



<p>The flow starts by the site calling this API, and some time later receiving a callback from the API on a specific endpoint of <em>SomeEndpoint.js </em>controller. Then the site makes an API call to get data (specific to a given user) for further processing. Some of it is saved in the <strong>privacy</strong> field of the session object. As stated in<a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/DWAPI/scriptapi/html/api/class_dw_system_Session.html?resultof=%22%70%72%69%76%61%63%79%22%20%22%70%72%69%76%61%63%69%22%20%22%73%65%73%73%69%6f%6e%22%20" target="_blank" rel="noreferrer noopener"> SFCC docs</a>, this field is a dictionary where we can store custom properties. The next step on the flow is to <strong>redirect to an action on the Login controller</strong>, and inside that action retrieve the information that was stored.</p>



<pre class="wp-block-code"><code>// SomeEndpoint.js controller
res.redirect(URLUtils.https("Login-Show"));

// Login-Show action
var apiResponse = session.privacy.myCustomField ? JSON.parse(session.privacy.myCustomField) : "";
// use apiResponse for further processing</code></pre>



<p>The problem happens when running the Login-Show action, <em>session.privacy.myCustomField</em> is equal to <em>null </em>so we can&#8217;t retrieve the information that was saved in the previous controller, before the redirect.</p>



<h2 class="wp-block-heading">Thinking about solutions</h2>



<p>First you try to keep using the session object provided by SFCC, but saving the data on another field called <em><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FDWAPI%2Fscriptapi%2Fhtml%2Fapi%2Fclass_dw_system_Session.html&amp;anchor=dw_system_Session_getCustom_DetailAnchor" target="_blank" rel="noreferrer noopener">custom</a></em>. The difference between custom and privacy is that data inside <em>custom</em> won&#8217;t be deleted when the user logs out.</p>



<p>Then we try to think of another approach because storing in any field of the session might not work. So we try to store this information in <a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fcustom_objects%2Fb2c_custom_objects.html" target="_blank" rel="noreferrer noopener">Custom Objects</a> (CO). It&#8217;s important to note a very important <strong>security detail with the custom objects approach</strong>. Creating and retrieving these custom objects happen in different controller actions. So in order for the second action to know how to retrieve the correct custom object that holds the API response data, it needs the ID for the CO. </p>



<p>Since moving from one action to the other happens through a redirect, we can only use query parameters. On top of that, the second action is Login-Show which renders HTML to the client in the end. Which means this <strong>custom object ID is publicly available</strong> in the user&#8217;s address bar&#8230; not good! This of course means you could simply type an ID in the URL and try to find a valid custom object containing some user&#8217;s data. Of course in the Login-Show action we can retrieve the custom object and delete it afterwards. But there is still a window where this data is accessible.</p>



<p>In order to prevent this exploit, we add code on the Login-Show action to validate the user accessing the login page is on the same session that initiated the login flow&#8230; but wait, did I just say &#8220;same session&#8221;. If we are having problems with this session not being the same, how can we guarantee validating this sessionID will work?? We have no guarantees basically.</p>



<p></p>



<p>After a lot of thinking, experimenting and reading docs, we decide to contact Salesforce by opening a support ticket. After that we were able to schedule a meeting and showed our problem. They investigated and got back to us with feedback on what was happening to the session, during the flow described earlier.</p>



<h3 class="wp-block-heading">Final solution</h3>



<p>The final solutions is&#8230; to not change any code. The problem was the <strong>hostname</strong> that was configured in the API that called the site. We simply configured it with the correct URL, which is the same domain in which the site uses when calling this API. In order to keep the correct session in the login page after the redirect, we made these changes:</p>



<p><strong>BEFORE</strong>: https://<strong>production-zone-digitmarket.demandware.net</strong>/on/demandware.store/Sites-Awesome-Site/pt_PT/SomeEndpoint-Action</p>



<p><strong>AFTER</strong>: https://<strong>awesome-domain.com</strong>/on/demandware.store/Sites-Awesome-Site/pt_PT/SomeEndpoint-Action</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Hopefully this post helped you know how session management works in Salesforce B2C Commerce Cloud. The moral of the story is: when code works everywhere except on one environment, it&#8217;s generally an environment <strong>configuration</strong> problem.</p>



<p>If you enjoyed this post or learned something from it, leave a comment with your thoughts.</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/">Session management in Salesforce B2C Commerce Cloud</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/davidpereira/2022/06/06/session-management-in-salesforce-b2c-commerce-cloud/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
