Item Search API Response Data not Cached

This topic applies to

Applies to

SuiteCommerce Advanced | Vinson


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.


Before proceeding, familiarize yourself with the Best Practices for Customizing SuiteCommerce Advanced.

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:

  1. If you have not done so already, create a directory to store your custom module.

  2. Open this directory and create a subdirectory to maintain your customizations.

    Give this directory a name similar to the module being customized. For example:


  3. In your new SessionExtension@1.0.0 module, create a subdirectory called JavaScript.


  4. In your new JavaScript subdirectory, create a JavaScript file to extend Session.js.

    Name this file according to best practices. For example:


  5. Open this file and extend the getSearchApiParams() method to add the pricelevel parameter to the Item Search API GET request.

    // Session.Fix.js // When Session.getSearchApiParams is called, this method adds the pricelevel param to the output define('Session.Extension' , [ 'Session' ] , function (Session) { 'use strict'; var original_getSearchApiParams = Session.getSearchApiParams; Session.getSearchApiParams = function () { var search_api_params = original_getSearchApiParams.apply(this, arguments); search_api_params.pricelevel = this.get('priceLevel', ''); return search_api_params; } });
  6. Save the file.

Step 2: Prepare the Developer Tools for Your Extension

  1. Open the SessionExtension@1.0.0 module.

  2. Create a file in this module and name it ns.package.json.


  3. Build the ns.package.json file using the following code

    { "gulp": { "javascript": [ "JavaScript/*.js" ] } }
  4. Save the ns.package.json file.

  5. Open the distro.json file.

    This file is located in the top-level directory of your SuiteCommerce Advanced source code.

  6. Add your custom module to the modules object.

    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", "version": "2.0", "buildToolsVersion": "1.3.0", "folders": { "modules": "Modules", "suitecommerceModules": "Modules/suitecommerce", "extensionsModules": "Modules/extensions", "thirdPartyModules": "Modules/third_parties", "distribution": "LocalDistribution", "deploy": "DeployDistribution" }, "modules": { "extensions/SessionExtension": "1.0.0", "suitecommerce/Account": "2.3.0", "suitecommerce/Address": "2.4.0", ...
  7. Include the module definition (“Session.Extension”) in the dependencies array of the Shopping application of the JavaScript object.

    Your distro.json file should look similar to the following:

    "tasksConfig": { //... "javascript": [ //... { "entryPoint": "SC.Shopping.Starter", "exportFile": "shopping.js", "dependencies": [ //... "Newsletter", "ProductDetailToQuote", //.. "Session.Extension" ],


    Best practice is to place any new modules at the bottom of the list in the dependencies array.

  8. 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:

  1. Navigate to the Product Display Page in your web store.

  2. Open the browser’s Developer Tools.

  3. View the Network XHR response data.

  4. Refresh your web store page.

  5. Verify that the items query contains the pricelevel parameter.

Related Topics