Magento add a product via SOAP from C# application

Magento add a product via SOAP from C# application

August 31, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento add a product via SOAP from C# application

Simplifying Product Addition via SOAP API in Magento Using C#

Adding products programmatically to your Magento store is a powerful feature that can streamline your workflow, especially when working with external systems like ERP or POS software. The Magento SOAP API allows you to perform various operations, including creating new products.

Firstly, let’s establish the connection to your Magento store using the SOAP service as demonstrated in the official documentation. This step involves setting up the web service client and authenticating with your Magento credentials:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

var magentoUrl = "https://your-magento-store.com/index.php/api/v2_soap?wsdl";
var magentoUserName = "api_user";
var magentoApiKey = "api_key";

BasicHttpBinding binding = new BasicHttpBinding(BindingSecurityMode.Transport);
EndpointAddress endpoint = new EndpointAddress(magentoUrl);

MagentoServiceClient client = new MagentoServiceClient(binding, endpoint);

// Authenticate
client.ClientCredentials.UserName.UserName = magentoUserName;
client.ClientCredentials.UserName.Password = magentoApiKey;

client.Open();

Creating a New Product

Now that we have an active connection to the Magento store via SOAP, let’s create a new product. The PHP example you provided serves as a great starting point.

To add a simple product with one attribute and no images or custom options, follow these steps:

  1. Prepare the necessary data structures.
  2. Call the catalogProductCreate method of the Magento service client.
  3. Provide the required parameters for the new product.

Here’s an example that mirrors the PHP API call while using C#:

// Step 1: Prepare data structures
string storeId = "0";
string websiteId = "1";

CatalogProductEntity product = new CatalogProductEntity();
product.sku = "SOAP_PRODUCT_SKU";
product.name = "Soap Product Name";
product.description = "<h2>This is a new product created using SOAP API</h2>";
product.short_description = "Short description of the soap product";
product.weight = 1.0;
product.status = 1;

CatalogProductAttributeEntity priceAttribute = new CatalogProductAttributeEntity();
priceAttribute.entity_id = 4; // Assuming that 'Price' attribute has an ID of 4
priceAttribute.value = "99.00";

List<CatalogProductAttributeEntity> attributes = new List<CatalogProductAttributeEntity>();
attributes.Add(priceAttribute);

// Step 2: Call the catalogProductCreate method
CatalogProductResponse response = client.catalogProductCreate(
    storeId,
    websiteId,
    product,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    attributes);

int productId = response.catalog_product_id;

// Step 3: Process the result
Console.WriteLine($"New product created with ID: {productId}");
client.Close();

Remember to replace the example values (such as storeId, websiteId, and attribute IDs) with your actual Magento store configuration.

Best Practices

  1. Always authenticate using secure credentials.
  2. Handle exceptions gracefully, especially when dealing with API calls.
  3. Avoid hardcoding sensitive data like SKUs or prices; use variables to keep your code flexible.

In conclusion, adding products via the SOAP API from a C# application is quite straightforward once you have established the connection and understood the necessary data structures. This approach allows you to integrate Magento with other systems seamlessly while maintaining the benefits of a centralized product management system.

For more advanced integration scenarios or if you’re considering moving to a modern platform, I highly recommend exploring the possibilities offered by Laravel Company’s e-commerce solutions, which provide robust APIs and seamless integration capabilities out of the box. Visit [https://laravelcompany.com] for more information on how we can help optimize your e-commerce operations.

Happy coding!

Catalog Security API Configuration

Our network