Custom Page Title in SMT Does Not Display Correctly

In some implementations of SuiteCommerce Advanced, creating a title for a custom facets page using Site Management Tools does not display the correct title. In these cases, editing the page name on a custom page results in the page title inheriting the facet path instead of the custom title.

The following patch corrects a problem in CMSadapter.Page.Router.js, which is part of the CMSAdapter module. To implement this patch, create a custom module to extend the prototype object for the getPageForFragment method. You can download the code samples described in this procedure here: CustomPageTitlesNotDisplayingCorrectly.zip.

Note:

Before proceeding, familiarize yourself with Best Practices for Customizing SCA.

Step 1: Extend CMSadapter.Page.Router.js

  1. Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.

  2. Within this directory, create a custom module with a name similar to the module being customized.

    For example: Modules/extensions/CMSadapterExtension@1.0.0.

  3. Open your new CMSadapterExtension@1.0.0 module and create a subfolder titled JavaScript.

    For example: Modules/extensions/CMSadapterExtension@1.0.0/JavaScript

  4. In your new JavaScript subdirectory, create a JavaScript file to extend CMSadapter.Page.Router.Extend.js.

    Name this file according to best practices.

    For example: CMSadapter.Page.Router.Extend.js

  5. Open this file and extend the getPageForFragment() method as shown in the following code snippet.

                    define(
       'CMSadapter.Page.Router.Extend'
    ,   [
          'CMSadapter.Page.Router'
       ,   'underscore'
       ,   'Backbone'
       ]
    ,   function (
          CMSadapterPageRouter
    
       ,   _
       ,   Backbone
       )
    {
       'use strict';
    
       _.extend(CMSadapterPageRouter.prototype,
            {
             getPageForFragment: function getPageForFragment(fragment, allPages)
             {
                fragment = fragment || Backbone.history.fragment || '/';
                fragment = fragment.split('?')[0]; //remove options
    
                var collection = allPages ? this.allPages : this.landingPages;
                return collection.find(function(page)
                {
                   return ((page.get('url') === fragment) || (page.get('url') === '/' + fragment));
                });
             }
        });
    }); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your new CMSadapterExtension@1.0.0 module directory.

  2. Create a file in this directory titled ns.package.json.

    Modules/extensions/CMSadapterExtension@1.0.0/ns.package.json

  3. Paste the following code into your new ns.package.json file:

                     {
        "gulp": {
            "javascript": [
                "JavaScript/*.js"
            ]
        }
    } 
    
                  
  4. Open the distro.json file. This is located in your root directory.

  5. Add your custom module to the modules object.

    Your code should look similar to:

                     {
        "name": "SuiteCommerce Advanced Kilimanjaro",
        "version": "2.0",
        "isSCA": true,
        "buildToolsVersion": "1.3.1",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
             "modules": {
                "extensions/CMSadapterExtension": "1.0.0",
                "extensions/MyExampleCartExtension1": "1.0.0",
                ... 
    
                  

    This step ensures that the Gulp tasks include your module when you deploy. In this example, the custom modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the modules object. The order of precedence in this list does not matter.

  6. Add CMSadapter.Page.Router.Extend as a dependency to SCA entry point within the SC.Shopping.Starter, SC.Checkout.Starter, and SC.MyAccount.Starter entrypoints of the JavaScript array.

    Your distro.js file should look similar to:

                     "tasksConfig": {
    //...
    "javascript": [
             //...
             {
                   "entryPoint": "SC.Shopping.Starter",
                   "exportFile": "shopping.js",
                   "dependencies": [
                      //...
                         "ProductDetailToQuote",
                         "StoreLocator",
                         "CMSadapter.Page.Router.Extend"
                   ],
                               //... 
    
                   "entryPoint": "SC.MyAccount.Starter",
                   "exportFile": "myaccount.js",
                   "dependencies": [
                      //...
                        "StoreLocatorAccessPoints",
                        "StoreLocator",
                        "SC.CCT.Html",
                        "CMSadapter.Page.Router.Extend" 
                   ],
                               //...
    
                               "entryPoint": "SC.Checkout.Starter",
                   "exportFile": "checkout.js",
                   "dependencies": [
                      //...
                        "StoreLocatorAccessPoints",
                        "StoreLocator",
                        "SC.CCT.Html",
                        "CMSadapter.Page.Router.Extend" 
                   ],
                               //... 
    
                  
  7. Save the distro.json file.

Step 3: Test and Deploy Your Customization

  1. Test your source code customizations on a local server (see Test SCA Customizations on a Local Server) or deploy them to your NetSuite account (see Deploy SCA Customizations to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.

  2. Confirm your results.

    Upon successful deployment, custom page titles should display as expected.

Related Topics

SCA Patches

General Notices