In Vinson releases of SuiteCommerce Advanced, the Item Search API response data is not cached in the Content Delivery Network (CDN) by default. To enable caching of the Item Search API response, you must customize your implementation to include the
pricelevel input parameter in the Item Search API query. Caching response data in the CDN is critical as it decreases Item Search API response time and improves application performance.
Step 1: Extend the Session.js File
This step explains how to extend the Session.js file, which is located in the Session module. You can download the code samples described in this procedure here: SearchApiCdnCache.zip.
If you have not done so already, create a directory to store your custom module.
Open this directory and create a subdirectory to maintain your customizations.
Give this directory a name similar to the module being customized. For example:
Name this file according to best practices. For example:
Open this file and extend the
getSearchApiParams() method to add the
pricelevel parameter to the Item Search API GET request.
// When Session.getSearchApiParams is called, this method adds the pricelevel param to the output
, function (Session)
var original_getSearchApiParams = Session.getSearchApiParams;
Session.getSearchApiParams = function ()
var search_api_params = original_getSearchApiParams.apply(this, arguments);
search_api_params.pricelevel = this.get('priceLevel', '');
Save the file.
Step 2: Prepare the Developer Tools for Your Extension
Open the SessionExtension@1.0.0 module.
Create a file in this module and name it ns.package.json.
Build the ns.package.json file using the following code
Save the ns.package.json file.
Open the distro.json file.
This file is located in the top-level directory of your SuiteCommerce Advanced source code.
Add your custom module to the
This ensures that the Gulp tasks include your extension when you deploy. In this example, the
extensions/SessionExtension module is added at the beginning of the list of modules. However, you can add the module anywhere in the
modules object. The order of precedence in this list does not matter.
"name": "SuiteCommerce Advanced Elbrus",
Include the module definition (
“Session.Extension”) in the dependencies array of the Shopping application of the
Your distro.json file should look similar to the following:
Best practice is to place any new modules at the bottom of the list in the
Save the distro.json file.
Step 3: Test and Deploy Your Extension
You are now ready to test your source code customizations on a local server (see SCA on a Local Server) or deploy them to your NetSuite account (see Deploy to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.
To verify that the Item Search API output response can now be cached in the CDN:
Navigate to the Product Display Page in your web store.
Open the browser’s Developer Tools.
View the Network XHR response data.
Refresh your web store page.
Verify that the items query contains the