Commerce Portal API - Setup Guide, Installation & Configuration.

TABLE OF CONTENTS

Introduction

This article provides a step-by-step process for setting up your Z10 CP API environment, installing necessary dependencies, and configuring services for local development. It's the perfect starting point for building, testing, and integrating API functionalities with ease. 


Prerequisites

Before you begin, ensure the following tools are installed on your system:

  • Download and Install Visual Studio:
    • Visit the official website: https://visualstudio.microsoft.com
    • Download the latest version of Visual Studio (Community, Professional, or Enterprise). These extensions help improve code quality, consistency, and readability:
  • Recommended (optional but helpful) Visual Studio extensions:
    • CodeMaid: A powerful tool for cleaning and organizing your code automatically.
    • Visual Studio Spell Checker: Helps detect spelling errors in your comments, strings, and text files.
    • Web Compiler 2022+: Compiles LESS, Sass, JSX, and especially CSS files. Very useful for frontend workflows.
  • Steps to install from the Visual Studio extension or download from the provided URLs.
    • Open Visual Studio
    • Go to Extensions > Manage Extensions
    • Search for each extension by name and click Download
    • Restart Visual Studio to complete the installation
    • Downloadable Link: 

Links :

CodeMaid download and install: Download Link

Visual Studio Spell Checker download and install: Download Link

Web Compiler 2022+  download and install: Download Link


Set up the Environment.

  • Setting Up the Commerce Portal Api Locally
    • Access the Repository:
      • Repository name: znode10-commerceportal-api
      • Ensure you have the necessary permissions to access the repo
    • Clone the Repository:
      • Open your terminal or Git Bash.
      • Run the following command:
      • git clone https://<your-repo-url>/znode10-commerceportal-api.git
      • Replace <your-repo-url> with your actual repository link.
    • Set Up Locally:
      • Navigate to the cloned folder:
      • cd znode10-commerceportal-api
  • Installing and Restoring NuGet Packages
    • Open Your Visual Studio Solution
      • Launch Visual Studio and open the solution file (.sln) of your project.
    • Configure NuGet Package Source
      • Go to Tools > NuGet Package Manager > Package Manager Settings.
      • Select Package Sources
      • Click the + button to add a new source:
      • Znode NuGet Source
      • GitHub NuGet Source (MRRSoft)
  • Setting the Startup Project in Visual Studio
    To run the Commerce Portal (CP) API, you need to set the correct project as the startup project in Visual Studio:
    • Open the Solution in Visual Studio.
    • In Solution Explorer, locate the project file:
      Znode.Engine.CommercePortal.Api.csproj
    • Right-click on the project and select:
      "Set as Startup Project"
    • The project name should appear in bold, indicating it will run when you start debugging.
  • Configuring appsettings.json of  CP API for Local Environment as below.
    • If we want to work along with admin, multifront API’s and others, please configure the below for respective Urls.
      • "ZnodeApiGateway": "https://apigateways-qa-znode.amla.io",
      • "ZnodeCommercePortalRootUri": "http://znode10apicp.znode:80",
      • "ZnodeApiV2RootUri": "http://znode10xapiv2.znode:80",
      • "ZnodeApiRootUri": "http://znode10xapi.znode:80"
    • Save and Rebuild
      • After updating, save the file and rebuild the solution to apply the changes.
    • Repeat the same settings mentioned in “A”  for Amdin, multifront API (V1, V2) to keep in connections in sync.
      Note: Make sure all related microservices use the correct local URIs in their appsettings.json.

Enable Caching

To improve performance, we need to enable caching in appsettings.json (Redis / SQL, you can allow Redis or SQL-based caching in your application.

  • Open appsettings.json
    In your microservice project (e.g., API/Commerce Portal API), locate and open the appsettings.json file.
  • Update the Caching Section
  • Add or update the following JSON block:
    "Caching": {  "Type": "ZnodeRedisCache", // Options: ZnodeRedisCache or ZnodeSqlCache
    "AbsoluteExpiration": "30",
    "SlidingExpiration": "20",
    "SqlCacheConnectionString": "Server=YOUR_SERVER;Database=YOUR_DB;User Id=USERNAME;Password=PASSWORD;TrustServerCertificate=True",
    "CacheSchemaName": "dbo",
    "CacheTableName": "SQLCache",
    "DeletionInterval": "30",
    "RedisCacheConnectionString": "localhost:6379",
    "RedisCacheInstanceName": "Dev",
    "InMemoryCacheKeys": "SiteConfig"
    }
  • Choose Caching Type
    Use "ZnodeRedisCache" for Redis (recommended for distributed environments). Use "ZnodeSqlCache" for SQL Server-based caching.
    Save & Restart Application
    After editing, save the file and restart your app to apply the changes.
  • Setting Up RabbitMQ for EventBus
    To improve performance, you can enable Redis or SQL-based caching in your application. This is optional but recommended for production-like environments.
    • Open appsettings.json
      • Find the file in your microservice project (e.g., API/Commerce Portal API), locate and open the appsettings.json file.
    • Update the EventBus Section
      • Add or update the following JSON block:

        "EventBus": {

          "MessageBrokerService": "RabbitMQ", // Use "RabbitMQ" to enable it

          "ServiceBusConnectionString": "YOUR_SERVICE_BUS_CONN_STRING", // Optional, if using Azure Service Bus

          "RabbitMQConnectionString": "amqp://guest:guest@localhost:5672", // Default local connection

          "RabbitMQManagementUrl": "http://localhost:15672", // Web UI access

          "RabbitMQUserName": "guest",

          "RabbitMQPassword": "guest",

          "QueueName": "base-cache-queue",

          "RetryCount": "2",

          "RetryInterval": "200",

          "EventRetry": "true"

  • Run RabbitMQ Locally 
    • Make sure RabbitMQ is installed and running on your system. You can use:
    • Access RabbitMQ Management UI 

      Go to http://localhost:15672

      Log in with the default:

      • Username: guest

      • Password: guest


Connecting to DB environments

Configuring Database Connection Strings in appsettings.json

To connect your application to your local database, replace the existing cloud-based connection strings with your local SQL Server credentials in the appsettings.json file.

  • Locate appsettings.json
    • Found in the root directory of each microservice (e.g., Admin, API V1/V2, CP API).
  • Update the ConnectionStrings Section
    • Replace the current Azure connection strings with your local machine’s SQL Server details:
    • Server: Name of your local SQL instance (e.g., localhost\SQLEXPRESS or just localhost)
    • Catalog: Your database name
    • User ID and Password: Your local DB credentials
    • "ConnectionStrings": { 

          "ZnodeECommerceDB": "Server=localhost;Initial Catalog=YourDBName;User ID=your_username;

      Password=your_password;TrustServerCertificate=True;",

           "Znode_Entities": "Server=localhost;Initial Catalog=YourDBName;User ID=your_username;

      Password=your_password;TrustServerCertificate=True;",

       "ZnodePublish_Entities": "Server=localhost;Initial Catalog=YourDBName;User ID=your_username;

      Password=your_password;TrustServerCertificate=True;",

       "ZnodeMongoDBForLog": mongodb://localhost:27017/Znode_Log",

           "Znode_CommercePortalDBEntities": "Server=localhost;Initial Catalog=YourDBName;User ID=your_username;

      Password=your_password;TrustServerCertificate=True;",

           "ZnodeFramework_Entities": "Server=localhost;Initial Catalog=YourDBName;User ID=your_username;

      Password=your_password;TrustServerCertificate=True;"

      }

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.