Extend Frontend Configuration Files in pre-Vinson implementations of SCA.

SCA enables you to configure the behavior of the frontend application by modifying configuration properties and objects. These properties are:

  • Stored in configuration files that define the objects that are loaded when the application starts.
  • Accessible to all modules within the application.

To extend a frontend configuration file:

1.Create the directory structure for your custom module.

In this example, the name of the custom module is Configuration, so the module directory would be Configurator@1.0.0.

2. Create the JavaScript subdirectory in your new module directory.

3. Create a new JavaScript file in the JavaScript directory of your custom module.

In this example, the name of the JavaScript file is Configurator.js

4. Add the mountToApp method to your custom JavaScript file.

For example, the code you add should look similar to:

define('Configurator'
,   [
        'SC.Configuration'
    ]
,   function (
        Configuration
    )
{
    'use strict';
    return  {
        mountToApp: function ()
        {
                     //Add your custom properties here.
        }
    };
});

This code performs the following tasks:

Lists the dependencies required. When customizing a configuration file, you must include the object it returns as a dependency.

Defines the mountToApp method. This method is required to load your custom module into the application. This method also contains the custom properties you are configuring.

5. Add your custom properties to the block within the mountToApp method as shown in the example above.

The following example shows how to redefine different configuration properties:

Configuration.imageNotAvailable = 'http://www.tnstate.edu/sociology/images/Image Not Available.jpg';

Configuration.addToCartBehavior = 'goToCart';

Configuration.facetDelimiters.betweenFacetNameAndValue = '%';

Configuration.productReviews.loginRequired = true;

Configuration.typeahead.maxResults = 4;

6. Create and edit the ns.package.json in the root directory of your custom module.

For example, the code you add should look similar to:

{
   "gulp": {
      "javascript": [
         "JavaScript/*.js"
      ]
   }
}

7. Update the distro.json file in the root directory of the SCA source directory. You must update this file in two places:

Add the name of your custom module to the list of modules defined in the modules object.

Add the name of your custom module to the dependencies of the application whose configuration file you are customizing. To ensure that your customized configuration properties are available to all modules, place your module at the top of this list.

8. View your changes.

If you are running a local server, you can view your changes by reloading your website.
If you are viewing your website in NetSuite, you can deploy your changes using the SCA developer tools.

Leave a comment

Your email address will not be published. Required fields are marked *