Extend Frontend Configuration Files
This example applies to pre-Vinson implementations of SuiteCommerce Advanced (SCA) only. For details about configuring SCA for Vinson or later releases, see Modify JSON Configuration Files.
Making changes to core source files or changing vital functionality of the application can make migrating to future releases difficult. Before making changes to SCA, see Best Practices for Customizing 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.
See Configure Properties for more information about these files and the properties they contain.
To redefine these properties for your installation, you must create a custom module that includes the original configuration file as a dependency.
To extend a frontend configuration file:
-
Create the directory structure for your custom module.
In this example, the name of the custom module is
Configuration
, so the module directory would beConfigurator@1.0.0
. -
Create the JavaScript subdirectory in your new module directory.
-
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
-
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.
-
-
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%20Not%20Available.jpg'; Configuration.addToCartBehavior = 'goToCart'; Configuration.facetDelimiters.betweenFacetNameAndValue = '%'; Configuration.productReviews.loginRequired = true; Configuration.typeahead.maxResults = 4;
-
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" ] } }
-
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.
-
-
View your changes.
If you are running a local server, you can view your changes by reloading your website. See Test SCA Customizations on a Local Server for more information.
If you are viewing your website in NetSuite, you can deploy your changes using the SCA developer tools. See Deploy SCA Customizations to NetSuite for more information.
Related Topics
- Example SCA Customizations
- Create a Custom Module
- Modify JSON Configuration Files
- Configure Facet Fields
- Extend the Backend Configuration File
- Add a Child View to a Composite View
- Override a Template File
- Extend a Sass File
- Add a Sticky Button
- Customizing the Loading Icon
- Adding a Custom Web Font
- Extending Font Awesome
- Displaying Device-Specific Carousel Images