Popular:
Create Variant (CSM-CRMV-03)
Overview
The Product Variant Creation feature facilitates the seamless integration of new variant details into the system as standalone entities. Unlike simple product variants that are tied closely to their parent products, these variants operate independently with predefined configurations, enhancing control over inventory management and product detailing. This granularity is pivotal for businesses that require precision in their inventory control and product customization capabilities. Utilization of the CSM-CRMC-06 API is necessary for fetching viable configuration values. Access to this feature mandates a valid authorization token coupled with MNRM permissions, ensuring robust security measures are in place for data transactions.
Pre-requirements
Before proceeding with the creation of a product variant, it’s essential to have:
- A parent product already created through the appropriate API, or
- A parent product specified by the Delivery team, contingent on the project’s nature.
API Endpoint:
[POST] /api-catalog/v2/customers/{customerId:long}/products/{configuratorRawMaterialId:long}/variants
Payload
Mandatory Parameters:
customerId(long): ID of the active customerconfiguratorRawMaterialId(long): ID of the parent product
Other Parameters:
Header: Include a valid authorization token
[POST] /api-catalog/v2
/customers/{customerId:long}
/products/{configuratorRawMaterialId:long}
/variants
{
"isActive": true,
"warehouseQuantity": 0,
"configuration": [
{
"attributeId": 0,
"valueId": 0
}
]
}
Response
Upon successful creation, the API returns the unique ID of the newly minted product variant.
Response DTO
In scenarios of successful operation or errors:
[200] OK: Signifies a successful operation. Returns0if there are no details specific to the newly created variant.[400] Bad Request: Indicates a malformed request or missing necessary parameters.[401] Unauthorized: Denotes invalid or absent authorization token, or the token lacks MNRM permissions.
[200] OK
0
[400] Bad Request
[401] Unauthorized
Example
using System;
using System.Threading.Tasks;
using RestSharp;
public static async Task CreateProductVariantAsync(long customerId, long configuratorRawMaterialId, bool isActive, int warehouseQuantity)
{
var client = new RestClient("https://apim-fe-staging.tailoor.com");
var request = new RestRequest($"/api-catalog/v2/customers/{customerId}/products/{configuratorRawMaterialId}/variants", Method.Post);
var currentToken = "token-recuperato-dalla-login";
request.AddHeader("Authorization", $"Bearer {currentToken}");
request.AddJsonBody(new
{
isActive = isActive,
warehouseQuantity = warehouseQuantity,
configuration = new {} // popolare con la configurazione della variante
});
try
{
var response = await client.ExecuteAsync(request);
if (response.IsSuccessful)
{
return response.Data; // Restituisce l'ID della variante creata
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ErrorMessage}");
return null;
}
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
return null;
}
}
Security
Ensure the HEADER of your request includes a valid authorization token. Creating new product variants is specifically reserved for users with MNRM permission, upholding strict access control and preserving data privacy.
Leveraging Product Variants
Viewing product variants as independent entities, each with its unique configuration, allows for more nuanced control over inventory and product offerings. This autonomy simplifies the management and tracking of distinct product variations and supports offline management and customization, thereby enhancing operational flexibility and market responsiveness.
Per ulteriori dettagli consultare Api.Web.Catalog

