Sana Assistant (online)
Table of Contents

Setup and configure SDK solution

From this article you will learn how to set up and configure Sana Commerce SDK solution for development purposes.

Prerequisites

In order to work with Sana Commerce SDK, the following prerequisites are required:

  1. Node.js v20 LTS
  2. TypeScript
  3. GIT (available in PATH)
  4. Visual Studio 2022 or Visual Studio Code
  5. Sana Commerce SDK package Download

Set Up the SDK

Unpack the downloaded SDK package into a new folder and perform the following preparation steps:

  1. Open the SDK solution in Visual Studio or VS Code

  2. Build the solution (it may take some time until all dependencies are restored)

  3. Run npm install at the root of ClientApp folder to install client-side packages

  4. Configure encryption keys and the authentication token secret. For the sake of this tutorial (since this is not a real project) any keys can be used. So, just specify the following values in the appsettings.json file under the Sana.Commerce.WebApp project:

    {
      "Security": {
        "Auth": {
          "TokenSecret": "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
        },
        "Aes": {
          "Key": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
          "Vector": "0123456789ABCDEF0123456789ABCDEF"
        }
      }
    }
    
  5. Restore out-of-the-box Sana SQL database to any SQL Server instance. The database backup or the corresponding SQL scripts can be found in Sana Commerce release package.

  6. Configure SQL connection string in the appsettings.Development.json or appsettings.User.json file under the Sana.Commerce.WebApp project to point to the previously restored database.

  7. Set Sana.Commerce.WebApp as the startup project and run it to make sure that everything has been correctly configured. There are 3 available profiles to run Sana.Commerce.WebApp:

    • IIS Express - selected by default, which runs lightweight IIS HTTP Server integrated to Visual studio. It allows to use some IIS-related features, but this method is not fastest during development.
    • Sana.Commerce.WebApp - recommended for development. Project profile, which runs the application using Kestrel server, which execution is faster than IIS Express.
    • Watch - runs application in a Watch mode, which tracks source files changes and executes .NET Core CLI run command. Also to make application start faster, make sure that you run app without debugger attached to it unless you have a reason for that.

Configure the Web Store

By default, the option to configure the initial Sana Admin user is disabled. To activate it, modify the CreateFirstAdminUser value from false to true in the appsettings.json file.

{
    "Features": {
        "CreateFirstAdminUser": {
          "Enabled": true
        }
    }  
}

Then, navigate to /admin in your browser and set up the first Sana Admin user.

After that, connect the web store to any ERP system or enable ERP "Mocked operations" to be able to develop an add-on without the real ERP connection.

Note

To enable ERP "Mocked operations", follow these steps:

  1. Open "ERP connection" page in Sana Admin, enter anything into the "Webservice URL" field and save changes.
  2. Go to the "Mocked operations" page, check all available operations and save changes.

Now, when the ERP connection is set up, navigate to the "System/Scheduled tasks" page and run the following tasks in the corresponding order:

  1. General information import
  2. Customer import
  3. Product import

Done. The web store is ready for further development.

What's next?

Continue with creating an Add-on project.