Categories Do Not Display Properly

In some implementations of the Kilimanjaro release of SuiteCommerce Advanced, the parent of a product category would incorrectly overwrite the data of a child category when it displays the child category. This could result in a Page Not Found (404) or the display of the wrong category

Create the Override File

  1. Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.
  2. Within this directory, create a custom module with a name similar to the module being customized.For example: Modules/extensions/CategoriesExtension@1.0.0.
  3. In your new CategoriesExtension@1.0.0 directory, create a folder titled SuiteScript.For example: Modules/extensions/CategoriesExtension@1.0.0/SuiteScript
  4. Copy the following source file and paste into the correct location:Copy This File:Place a Copy Here:Modules/suitecommerce/Categories@X.Y.Z/SuiteScript/Categories.Model.jsModules/extensions/Categories@X.Y.Z/SuiteScriptIn this example, X.Y.Z represents the version of the module in your implementation of SuiteCommerce Advanced.
  5. Open your new copy of Categories.Model.js and locate the following lines:
                if (cat)
{
  if (cat.isprimaryurl === 'T')
  {
    cat.idpath = category.idpath;
    cat.canonical = cat.fullurl;
    }
    else
    {
      cat.canonical = category.fullurl;
    }
  }
  else
  {
    categories[line.getValue('internalid')] = category;
  } 

                              if (cat)
{
  if (category.isprimaryurl === 'T')
  {
    cat.canonical = category.fullurl;
  }

  if (categoryIds && categoryIds.fullurl === category.fullurl)
  {
    cat.idpath = category.idpath;
  }
}
else
{
  category.canonical = category.fullurl;
  categories[line.getValue('internalid')] = category;
} 

              

Prepare the Developer Tools For Your Customization

  1. Open your Modules/extensions/CategoriesExtension@1.0.0 module directory.
  2. Create a file in this directory titled ns.package.json.Modules/extensions/CategoriesExtension@1.0.0/ns.package.json
  3. Paste the following code in your new ns.package.json file:
                {
   "gulp": {
      "javascript": [
         "JavaScript/*.js"
      ]
   },
   "overrides": {
      "suitecommerce/Categories@X.Y.Z/SuiteScript/Categories.Model.js" : "SuiteScript/Categories.Model.js"
   }
} 

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

Add your custom module to the modules object.

Your code should look similar to:
                {
  "name": "SuiteCommerce Advanced Kilimanjaro",
  "version": "2.0",
  "isSCA": true,
  "buildToolsVersion": "1.3.1",
  "folders": {
    "modules": "Modules",
    "suitecommerceModules": "Modules/suitecommerce",
    "extensionsModules": "Modules/extensions",
    "thirdPartyModules": "Modules/third_parties",
    "distribution": "LocalDistribution",
    "deploy": "DeployDistribution"
    },
    "modules": {
        "extensions/CategoriesExtension": "1.0.0",
        "extensions/MyExampleCartExtension1": "1.0.0",            ... 

              

Leave a comment

Your email address will not be published. Required fields are marked *