Pages Not Indexed Using Google’s Mobile-First Indexing

In some cases, search engine crawlers discard content from the page generator and do not load all the required resources to render pages correctly. This results in SuiteCommerce pages not rendering content. Applying this patch corrects this issue by maintaining the SEO pre-render result.

This patch uses the override method to replace shopping.ssp, located in the ShoppingApplication module. You can download the code samples described in this procedure here: MobileFirstIndexingPatch.zip.

Note:

In general, NetSuite best practice is to extend JavaScript using the JavaScript prototype object. This improves the chances that your customizations continue to work when migrating to a newer version of SuiteCommerce Advanced. However, this patch requires you to modify an SSP file, which requires that you use a custom module to override the existing module file. For more information, see Develop Your SCA Customization.

Step 1: Create the shopping.ssp Override File

  1. Open the Modules/extensions directory and create a subdirectory to maintain your customizations and store your custom module.

    Give this subdirectory a name similar to the module being customized. For example: Modules/extensions/ShoppingApplication.Extension@1.0.0.

    Note:

    If you are implementing the Elbrus release of SCA or later, the extensions directory already exists in your source code. If implementing Vinson release or earlier, you must add it manually.

  2. In your new ShoppingApplication.Extension@1.0.0 directory, create a subdirectory called SuiteScript.

    For example: Modules/extensions/ShoppingApplication.Extension@1.0.0/SuiteScript

  3. Find the following file in your existing source:

    Modules/suitecommerce/ShoppingApplication@X.Y.Z/shopping.ssp

    In this example, X.Y.Z represents the version of the module in your implementation of SuiteCommerce Advanced.

  4. Copy this entire file and paste a copy in your new module’s SuiteScript directory.

    For example: Modules/extensions/ShoppingApplication.Extension@1.0.0/SuiteScript/shopping.ssp

  5. Open your new copy of shopping.ssp and locate the following line:

                    document.getElementById("main").innerHTML = ''; 
    
                  
  6. Replace this line with the following code:

                    if (!navigator.userAgent.match(/googlebot/i))
    {
       document.getElementById('main').innerHTML='';
    } 
    
                  
  7. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your ShoppingApplication.Extension@1.0.0 module directory.

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

    For example: Modules/extensions/ShoppingApplication.Extension@1.0.0/ns.package.json

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

                    {
       "gulp": {
           "ssp-files": {
               "SuiteScript/shopping.ssp": "shopping.ssp"
           }
       },
       "overrides": {
           "suitecommerce/ShoppingApplication@X.Y.Z/SuiteScript/shopping.ssp" : "SuiteScript/shopping.ssp"
       }
    } 
    
                  

    In your code, replace X.Y.Z with the version of the module in your implementation of SuiteCommerce Advanced.

  4. Open the distro.json file. This is located in your root directory.

  5. Add your custom module to the modules object.

    Your code should look similar to the following example:

                    {
        "name": "SuiteCommerce Advanced 2018.2.0 (sc-2018.2.0)",
        "version": "2.0",
        "isSCA": true,
        "buildToolsVersion": "sc-2018.2.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
            "extensions/ShoppingApplication.Extension": "1.0.0",
            "suitecommerce/Account": "sc-2018.2.0",
                 ... 
    
                  

    This ensures that the Gulp tasks include your module when you deploy. In this example, the custom modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the modules object. The order of precedence in this list does not matter.

  6. Save the distro.json file.

Step 3: Test and Deploy Your Customization

  1. Test your source code customizations by deploying them to your NetSuite account (see Deploy SCA Customizations to NetSuite).

    Note:

    Since this patch modifies a SuiteScript file, changes are not visible in your local environment. SuiteScript files run on the server and must be deployed to NetSuite to take effect.

  2. Confirm your results.

Related Topics

SCA Patches

General Notices