Configure or Disable Core SCA Functionality

In the recent Mont Blanc release of SCA, we added a number of new items of functionality such as the ability to restrict access to your site, whether it is your entire site or just price information. Along with that, we included some documentation on how to enable or disable this functionality, and it is this that I want to walk you through.

Backend Configuration File

In a previous article on how to customize the homepage, I talked about the frontend configuration files that you can modify to make changes. One of the key files that we will cover in this article is Configuration.js, which is located in Modules > suitecommerce > SspLibraries.

Like the frontend configuration files, it contains a number of settings that toggle on and off functionality and define how they behave. However, there are a few key facts that make it a little different from frontend configuration files:

  1. Although written in JavaScript, it is, in this context, SuiteScript. It is being executed on the server.
  2. As it is being executed on the server, any modifications you want to make will need to be pushed up to the server for them to take effect, even when working locally.
  3. It is combined with other configuration files to make ssp_libraries.js, which is created when you run gulp deploy and stored in the top level of the DeployDistribution directory.

With that in mind, I'm going to quickly run through how to make changes to the configuration file before providing some concrete examples on the things you can do.

Make Configuration Changes

As always: you shouldn't modify the file directly, you should instead create a separate file that extends it. There isn't actually much for me to say about this as we have written up how to do this in the documentation, see Extending the Backend Configuration File for instructions. The steps are roughly as follows:

  1. Create the directory structure for the extension file.
  2. In the extension file, include the configuration file as a dependency.
  3. Create a ns.package.json file.
  4. Update distro.json to include the extension in the modules array and in the dependencies array of the ssp-libraries object.
  5. Deploy to NetSuite.

Once that file is in place, and you've deployed it successfully, you can check in ssp_libraries.js to see that it's been included:

With that in mind, let's take a look at some of the configurations you can make. For example, you can use this file to disable any core SCA functionality that you don't want.

Example Configuration Changes

So part of the purpose of this article is to answer the question: how do I disable unwanted functionality? After all, we've created SCA so that it is flexible enough to be excellent in a lot of cases, but we recognize that sometimes that functionality isn't required by all our users.

The documentation provides the example of disabling the site management tools. The beautiful simplicity of the system is that you can disable it just by entering config.useCMS = false into your custom configuration file.

Similarly, you can enable and disable a multitude of functionality simply by overriding the values in Configuration.js such as restricting access to your site, restricting access to prices and multiple shipping addresses.

Product Lists

That's simple enough, but what we've been asked about one unusual case that doesn't have a toggle, specifically the product lists functionality that powers the wish list functionality? To find out, we have to look at the code that uses the settings in Configuration.js to figure out what we need to do.

Well, actually, in this case you can just toggle it off. In your override file, put config.product_lists = false;. When ssp_libraries.js is created, it will override the property's value with false. Where is this value used? In Modules > suitecommerce > ProductList > javascript > ProductList.Utils.js there is a function, included below for reference:

isProductListEnabled: function ()
{
    return !!application.getConfig('product_lists');
}

An explanation, if you're unfamiliar with it, is that !! forces a precise boolean representation of something; it is, essentially, the ! operator twice. So while a single ! would convert product_lists to a boolean and then return the opposite value, using !! transforms it into a boolean and then returns its truthiness. Thus, if we set product_lists to false then all we are doing is converting it to true and back to false again. Conversely, the function returns true if we provide it with any value (such as an array of values) that isn't a falsey one.

Thus, this is an effective way of determing whether the functionality is enabled: if it we've provided settings, then it is enabled; if we haven't, then it's not.

The image below illustrates what happens in My Account after you set config.product_lists to false.

Obviously, this is just one area and it affects other areas of the site but this gives you an idea of the effect it has: seamless removal of functionality from the site. You can see a similar effect on the product detail page, for example.

If you look at Configuration.js you'll see that numerous items of core SCA functionality can be configured — or, indeed, toggled on or off — using this file. We've written these settings in our backend configuration documentation.

Summary

In addition to the frontend configuration files we have included a backend configuration file. One of its unique characteristics is that it is a SuiteScript file, which is stored as an SSP library on the server. This file contains settings for core SCA functionality, such as product lists, site management tools, restricting access to your site, and others.

To change the default settings in Configuration.js you need to extend it, and this is what we've discussed. We have explicit details on how to make this extension in our documentation.

Further Reading