Item Record HTML Meta Data Not Appearing on Page Meta Data

Elbrus implementations of SuiteCommerce Advanced experience an issue where the value of an Item record’s Meta Tag HTML field does not appear in the page’s meta data. To correct this issue, create a custom module to extend ProductDetails.Base.Views.js as described in this section.

In addition to making these changes, you must create an ns.package.json file and update your distro.json file for any custom modules you include. You can download the code samples described in this procedure here: HTMLMetaTagsNotAppearingPatch--Elbrus.zip.

Step 1: Extend the ProductDetails.Base.Views.js File

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

    Following best practices, name this directory extensions and place it in your Modules directory. Depending on your implementation and customizations, this directory might already exist.

  2. Open your extensions directory and create a custom module to maintain your customizations.

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

    Modules/extensions/ProductDetails.Extension@1.0.0/

  3. In your new module, create a subdirectory named JavaScript.

  4. In your JavaScript subdirectory, create a new JavaScript file.

    Give this file a unique name that is similar to the file being modified. For example:

    Modules/extensions/ProductDetails.Extension@1.0.0/ProductDetails.Base.View.Extension.js

  5. Open this file and set it up to overwrite the getMetaTags() method of the ProductDetails.Base.View.js file.

    Your file should match the following code snippet:

                    define(
       'ProductDetails.Base.View.Extension'
    ,   [
          'ProductDetails.Base.View'
    
       ,   'jQuery'
       ,   'underscore'
       ]
    ,   function (
          ProductDetailsBaseView
    
       ,   jQuery
       ,   _
       )
    {
       'use strict';
    
       return {
           mountToApp: function ()
           {
             _.extend(ProductDetailsBaseView.prototype,
             {   
                getMetaTags: function getMetaTags ()
                {
                   return jQuery('<head/>').html(
                      jQuery.trim(
                         this.model.get('item').get('_metaTags')
                      )
                   ).children('meta');
                }
             });
          }
       }
    }); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools for Your Customizations

  1. Open the ProductDetails.Extension@1.0.0 module.

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

    Modules/extensions/ProductDetails.Extension@1.0.0/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 to ensure that the Gulp tasks include it when you deploy.

    Your code should look similar to the following example:

                    {
        "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/ProductDetails.Extension": "1.0.0",
            "extensions/MyExampleCartExtension1": "1.0.0",
                    //... 
    
                  
  7. Include the module definition (ProductDetails.Base.View.Extension) as a dependency within the JavaScript SC.Shopping.Starter entry point.

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

                    "tasksConfig": {
    //...
          "javascript": [
             {
                 "entryPoint": "SC.Shopping.Starter",
                 "exportFile": "shopping.js",
                 "dependencies": [
                    //...
                  "StoreLocator",
                  "ProductDetails.Base.View.Extension"
                 ]
                 //...
             }
    //... 
    
                  
  8. Save the distro.json file.

Step 3: Test and Deploy Your Extension

  1. Test your source code customizations on a local server (see Test SCA Customizations on a Local Server) or deploy them to your NetSuite account (see Deploy SCA Customizations to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.

  2. Confirm your results.

    Upon successful deployment, your Item record Meta Tag HTML value should appear in the meta data within the DOM of the associated product details page.

Related Topics

SCA Patches

General Notices