Categories Navigate Adapter Event Removed in SMT

In the 18.2 release of SuiteCommerce Advanced, the categories:navigate adapter event in SMT was removed. Consequently, SMT admins cannot preview current and future dated categories, as well as the preview of the category structure and the items in the categories. The patch instructions described below correct this problem.

To implement this patch, create a custom module to override CMSadapter.Impl.Categories.v3.js, which is part of the CMSadapter module. You can download the code samples described in this procedure here: CategoriesNavigateAdapterEventRemovedinSMT.

Note:

In general, NetSuite best practice is to extend JavaScript using the JavaScript prototype object. This improves the chances that your customizations continue to work when migrating to a newer version of SuiteCommerce Advanced. However, this patch requires you to modify a file in a way that you cannot extend, and therefore requires you to use a custom module to override the existing module file. For more information, see Develop Your SCA Customization.

Step 1: Create the Override File

  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. In your new CMSadapterExtension@1.0.0 directory, create a folder titled JavaScript.

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

  4. Copy the following source file and paste into the correct location:

    Copy This File:

    Place a Copy Here:

    Modules/suitecommerce/CMSadapter@X.Y.Z/JavaScript/

    Modules/extensions/CMSadapterExtension@1.0.0/JavaScript

    In this example, X.Y.Z represents the version of the module in your implementation of SuiteCommerce Advanced.

  5. Open your new copy of CMSadapter.Impl.Categories.v3.js and locate the listenForCMS() method.

  6. Inside the listenForCMS() method, add the following event:

                    self.CMS.on('categories:navigate', function (promise, data)
    {
      Backbone.localCache = {};
    
      Backbone.history.navigate(url, { trigger: false });
      Backbone.history.loadUrl(url);
    
      self.reloadCategories({ 'dontRefresh': true }).then(function()
      {
        promise.resolve();
         });
    }); 
    
                  
  7. Locate the following header of the reloadCategories() method:

                    CMSadapterImplCategories3.prototype.reloadCategories = function () { 
    
                  

    Change the header of the reloadCategories() to the following code:

                    CMSadapterImplCategories3.prototype.reloadCategories = function (options) { 
    
                  
  8. Locate the following line in the reloadCategories() method:

                    self.refreshPLP(); 
    
                  
  9. Replace this line with the following code:

                    if (!(options && options.dontRefresh))
    {
      self.refreshPLP();
    } 
    
                  
  10. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your Modules/extensions/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 in your new ns.package.json file:

    Important:

    You must replace the string X.Y.Z with the version of the module in your implementation of SuiteCommerce Advanced.

                    {
       "gulp": {
          "javascript": [
             "JavaScript/*.js"
          ]
       },
       "overrides": {
          "suitecommerce/CMSadapter@X.Y.Z/JavaScript/CMSadapter.Impl.Categories.v3.js" : "JavaScript/CMSadapter.Impl.Categories.v3.js"
       }
    } 
    
                  
  4. Open the distro.json file. This file is located in your root directory.

  5. Add your custom module to the modules object.

    Your code should look similar to:

                     {
        "name": "SuiteCommerce Advanced 2018.2.0 (sc-2018.2.0)",
        "version": "2.0",
        "isSCA": true,
        "buildToolsVersion": "sc-2018.2.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
            "extensions/CMSadapterExtension": "1.0.0",
            "suitecommerce/Account": "sc-2018.2.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. 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, you can go to to both current and future dated categories in SMT.

Related Topics

SCA Patches

General Notices