Patch Using Override Mode

If you want to implement a patch that corrects an issue by overriding a method, follow the steps in this procedure. Remember to use override mode for patches only when you need to modify a file in a way that cannot be accomplished using extend mode. You can access the instructions for each patch from a list provided in SCA Patches.

Note:

Before proceeding, familiarize yourself with Best Practices for Customizing SCA.

Step 1: Create the Override File

  1. Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.

    • If you’re patching SCA 2019.1 and earlier, create the extensions directory in the Modules directory.

    • If you’re patching SCA 2019.2 and later, create the extensions directory in the directory where the module that contains the file you want to override resides.

  2. Within the extensions directory, create a subdirectory with a name similar to the module you need to patch.

    A good pattern to follow is: .../extensions/<module_name>Extension@<extension_version>

    For example, if you need to patch the CMSadapter module, name your subdirectory: CMSadapterExtension@1.0.0.

  3. Open the custom module subdirectory from the preceding step and create a new subdirectory with a name that reflects the type of file you need to override. Possible types include: JavaScript, SuiteScript, Templates.

    For example: .../extensions/CMSadapterExtension@1.0.0/JavaScript

  4. Copy the source file that you want to override and paste it into the JavaScript, Suitescript, or Templates subdirectory from the preceding step.

    For example, to override the MSadapter.Component.js file in SCA 2018.2, you would:

    Copy This File:

    Place the Copy Here:

    Modules/suitecommerce/CMSadapter@X.Y.Z/JavaScript/CMSadapter.Component.js

    Modules/extensions/CMSadapterExtension@1.0.0/JavaScript

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

  5. Paste the code provided in your patch instructions into your copy of the source file that you want to override. Make sure you replace the specific blocks or lines of code as instructed.

  6. Save the file.

Step 2: Prepare the Developer Tools For Your Patch

  1. Open the custom module directory you created in the first part of this procedure. For example, if you are patching the CMSadapter module, open the CMSadapterExtension@1.0.0 directory.

  2. Create a file in the custom module directory named ns.package.json.

    For example: .../extensions/CMSadapterExtension@1.0.0/ns.package.json

  3. Paste the code provided in your patch instructions into the new ns.package.json file.

    The code provided for the ns.package.json file is specific to the file that you want to override.

  4. In the top level of the SuiteCommerce Advanced directory, open the distro.json file.

    Note:

    For SuiteCommerce Advanced 2019.2 and later, the distro.json file is located in the Advanced directory. For example: SuiteCommerce Advanced 2019.2/SC_19.2_Live/Advanced/distro.json.

  5. Add your custom module to the modules object in the distro.json file.

    Add your custom module to the list of existing values that follow the “modules”: key as shown in the following example.

    Note:

    Values for keys in the modules object are release-specific and so the following example may not look exactly like the object in your distro.json file. Be sure to add your module to the list of existing values exactly as shown in the instructions for your patch.

                    {
        "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/CMSadapterExtension": "1.0.0",
                "extensions/MyExampleCartExtension1": "1.0.0",
                ... 
    
                  

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

  6. Save the distro.json file.

Step 3: Test and Deploy Your Patch

How you test and deploy depends on your patch.

Related Topics

Patches Overview
Patch Using Extend Mode

General Notices