Search Engine: Elastic

Article ID: 130479, created on Mar 21, 2017, last review on May 18, 2017

Table of Contents

  • 1. Symptoms
  • 2. Resolution
  • 3. Why do you need to do it?
  • 4. To run it, perform the following steps
  • 5. Workflow
    • 5.1 Reusing files that you obtained during the utility execution in the sandbox environment
    • 5.2 Checking your layout templates for possible conflicts
    • 5.3 Preparing layout templates
    • 5.4 Importing layout templates back to Billing
  • 6. How to update templates manually
  • 7. How to revert the changes

Symptoms

Before upgrading to Odin Automation Billing 7.1, a pre-check report and a log file contain a message that you are using customizations in online store templates that should be updated to the latest version delivered with the new release of Odin Automation, and after upgrading Odin Automation Billing to version 7.1, you must perform some steps.

Resolution

After upgrading Odin Automation Billing to version 7.0 or 7.1, we recommend that you run a special script called "store-templates-assistant", which will help you update all customizations in existing layout templates to the newest versions.

Why do you need to do it?

Each online store can be customized by modifying layout templates. These changes are applicable only to the Online Store version in which they are made. When a new Online Store version is released, it is possible that the layout templates on which customizations were based were changed as well. These changes might be critical: If they are missing from the customized layout templates, the online store might be inoperable.

To simplify the updating of layout templates, we created a special utility called "store-templates-assistant".

To run it, perform the following steps:

  1. Check whether PostgreSQL installed on the Billing database node is configured to allow connections from the Odin Automation management node. Connect to the Billing database node over SSH and check the '/var/lib/pgsql/9.6/data/pg_hba.conf' file. This file must contain a line similar to the following:

    host all all <MN_IP_ADDRESS> 255.255.255.255 md5

    where '<MN_IP_ADDRESS>' is an IP address of the Odin Automation management node. If you cannot find such a line in the "pg_hba.conf" file, add it in the end of the file:

    host all all <MN_IP_ADDRESS> 255.255.255.255 md5

    Restart PostgreSQL.

  2. Download the store-templates-assistant.tar.gz file to the Odin Automation management node.

  3. Issue the command: tar -zxf ./store-templates-assistant.tar.gz

  4. Issue the command: cd ./store-templates-assistant

Workflow

  1. Retrieve a list of customized stores and layout templates with possible conflicts.

    # ./store-templates-assistant --check-possible-conflicts --all --detailed

  2. Export the customized layout templates from Billing to a file system and apply the changes from the latest Billing version to it.

    # ./store-templates-assistant --prepare-templates --all

  3. If the utility could not apply the changes automatically, you will be prompted to apply the changes manually. Select one of the stores for editing and edit all its templates that were not updated automatically. After you finish editing the store, you can go to the step 4 and import the changed templates back to Billing.

    All templates of the selected store are located at the following path:

    ./output/store-<StoreID> where StoreID is a unique ID of the selected store.

    You can learn how to do so in the section How to update templates manually.

  4. Start importing the changed templates of an online store back to Billing.

    # ./store-templates-assistant --apply-templates --store-id=<StoreID>

    Note: To simplify the process of applying manual changes to similar templates in different online stores, the utility will automatically find such customizations in other stores and will correct them.

    Important: Before you start importing templates back to Billing, double-check to make sure that all templates were properly corrected and that they do not contain errors, otherwise the online store might be inoperable.

  5. Edit the next store, and return to the step 4.

Reusing files that you obtained during the utility execution in the sandbox environment

If you upgraded Odin Automation in a sandbox environment and updated all layout templates by means of the utility, we recommend that you keep the cache of the utility. You can use this cache to update layout templates in a production environment. In this case, you will not have to manually edit the templates again: they will be updated automatically.

Steps to perform (all paths are specified relative to the path where the utility is located):

  1. Archive the utility's cache in the sandbox environment:

    cd ./lib/data

    tar -zcf .hash-<target OA version>.tar.gz .hash-<target OA version>

  2. Copy the resulting file to your local computer.

  3. Install the utility in a production environment. You can learn how to do so in the section To run it, perform the following steps.

  4. Make sure that you are in the directory containing the "store-templates-assistant" utility.

  5. Go to the directory "./lib/data":

    cd ./lib/data

  6. Copy the cache archive you previously prepared to this directory and issue the command:

    tar -zxf .hash-<target OA version>.tar.gz

    After running this command, a new directory starting with the prefix '.hash-' in a name will appear in the directory './lib/data'.

  7. Start preparing templates as described in Workflow > 2..

    All online stores will be updated automatically.

    Important: If there are customized templates in the production environment that were missing from the sandbox environment, you will need to manually edit them.

  8. Start uploading templates back to Billing. You can learn how to do so in the section Workflow > 4.

Checking your layout templates for possible conflicts

This is a quick analysis of templates that contain customizations, which might become inoperable after upgrading Online Stores. This command only informs you about the possible issues. You can use it anytime.

Issue the command:

./store-templates-assistant --check-possible-conflicts --all - Shows a list of affected stores.

or

./store-templates-assistant --check-possible-conflicts --all --detailed - Shows a list of affected stores and affected templates.

This command does the following:

  • Exports layout templates from Billing to a local file system.
  • Automatically analyzes whether the exported templates are compatible with the templates shipped in the latest Billing version.
  • Shows a list of online stores and templates that can be potentially corrupted after upgrade to the current Billing version.

Preparing layout templates

Use this command to automatically update your layout templates to the latest versions shipped with the latest Online Store update. If any critical incompatibility issues are detected during an attempt to update templates, you will be prompted to edit such templates manually using a text editor. If there are online stores for which all templates were updated successfully, you will be prompted to import such online stores back to Billing immediately.

Issue the command: ./store-templates-assistant --prepare-templates --all

This command does not change anything in Billing. If there are stores in which all customizations were updated automatically, the utility will prompt you to import all changes to Billing. We recommend that you check the results of automatic updating before importing changes to Billing.

This command does the following:

  • Exports layout templates from Billing to a local file system.
  • Automatically analyzes whether the exported templates are compatible with the templates shipped in the latest Billing version.
  • Automatically makes changes to the exported templates to ensure the proper operation of the online stores.
  • Provides a detailed report about the operations performed by the utility and explains how to resolve any incompatibility issues with the exported templates.

Note: If you run the command --prepare-templates the second time, it will remove all templates with your changes that were previously exported from Billing. In such a case, you can lose all your changes if you proceed with running this command by responding "Yes" when prompted to confirm: "Continue anyway?"

Importing layout templates back to Billing

Issue the command: ./store-templates-assistant --apply-templates --store-id=<StoreID>

or

Issue the command: ./store-templates-assistant --apply-templates --all - to import all online stores.

This command automatically analyzes all exported templates, including those that you previously corrected, and imports the online stores whose templates do not contain any conflicts. For all other stores, you will be prompted to correct templates to resolve conflicts.

Before you start importing templates back to Billing, double-check to make sure that all templates were properly corrected and that they do not contain errors.

This command does the following:

  • Imports updated templates back to Billing.
  • Runs the synchronization between Billing and online stores.

How to update templates manually

  1. Go to the directory that contains the patched layout templates:

    # cd ./output

    # cd ./store-<StoreID> - where StoreID is the unique ID of the online store that you want to edit.

    Note: You can learn the path to the directory with online store templates in the utility's output. Locate the following lines:

       The location of the patched layout templates:
       /usr/local/pem/share/online-store-templates/output/store-1
    
  2. For all customized templates that were not updated by the utility automatically, special files with the extensions.tpl.yours and .tpl.latest-release will be created:

    • .tpl.yours - Your layout templates that were exported from Billing before updating.
    • .tpl.latest-release - The original templates delivered with the latest release by Odin without your customizations.

    Note: These files are created for technical reasons. They will not be imported to Billing.

    Important: Do not delete or modify these files. They are needed for the proper operation of the utility.

  3. Locate the templates with the .tpl extension that contain conflicts and try resolving them. A file conflict occurs when two or more developers have changed the same few lines of a file. To resolve conflicts, you can use any text editor to manually edit the conflicting lines.

    • .tpl - Updated templates delivered with the latest release by Odin that contain your customizations. We recommend that you verify the contents of such templates before importing them back to Billing.

    Note: All files with the .tpl extension will be imported back to Billing. For this reason, we recommend that you verify the contents of all templates (including those automatically updated by the utility) before importing them back to Billing.

    The conflicting area of a file contains two blocks divided by the markers <<<<<<<, =======, >>>>>>>. The upper block contains the changes delivered in the latest release, and the lower block contains the changes you made to this template, before upgrade.

    Example:

     <<<<<<<
     the changes delivered in the latest release
     =======
     the changes you made to this template, before upgrade
     >>>>>>>
    

    You should decide how the code should look like, make the necessary changes, and save the file. As a result, a file with the resolved conflicts should not contain any conflict markers such as <<<<<<<, =======, >>>>>>>.

If you think that your layout templates that were exported from Billing before updating must remain unchanged in Online Store (such as when your templates contain many customizations and, for this reason, contain many conflicting blocks), you can issue the following command:

cp ./output/store-<StoreID>/<template_name>.tpl.yours ./output/store-<StoreID>/<template_name>.tpl

The template file prepared for uploading to Billing will be replaced with your file.

  1. After resolving all merging conflicts, you can rewrite the existing layout templates in Billing using this command:

    ./store-templates-assistant --apply-templates --store-id=<StoreID>

    Important: Before you start importing templates back to Billing, double-check to make sure that all templates were properly corrected and that they do not contain errors, otherwise the online store might be inoperable.

How to revert the changes

If you imported a store to Billing and encountered errors in the operation of the online store, you can revert changes in layout templates by going to: Odin Automation Billing > Online Store > Layout Templates. Select the templates that you want to revert. You can find all the layout templates that were imported by the store-templates-assistant utility by searching for this description:

Automatically updated to the version ....

Email subscription for changes to this article
Save as PDF