Import products from b2b.msan.hr

In this blog, we’ll walk through the process of creating a custom plugin to import product data from the MSAN B2B API, specifically using the endpoint:
https://b2b.msan.hr/B2BService/HTTP/Product/GetProductsList.aspx

This API returns product data in XML format and requires valid API credentials along with certificates for secure access. We’ll use a cURL request to fetch the data, parse the XML response, and import the products into a WooCommerce store. This integration ensures your product catalog remains up to date by automatically syncing from MSAN’s B2B service.


Curl Request:


  $ch = curl_init(); 
  curl_setopt($ch,CURLOPT_URL,"https://b2b.msan.hr/B2BService/HTTP/Product
  /GetProductsList.aspx"); 
  curl_setopt($ch, CURLOPT_VERBOSE, 1); 
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); 
  curl_setopt($ch, CURLOPT_CAINFO, "/path to/ca.pem"); 
  curl_setopt($ch, CURLOPT_SSLCERT, "/path to/client.pem"); 
  curl_setopt($ch, CURLOPT_SSLKEY, "/path to/key.pem");  
  curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "{keypswd}"); 
  curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch); 
  $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);


Get Price Curl Request:

In addition to fetching product details, the MSAN B2B API also provides a dedicated endpoint to retrieve updated product pricing. To get the latest prices, we use a similar cURL request as before, but with the following URL:
https://b2b.msan.hr/B2BService/HTTP/Product/GetProductsPriceList.aspx

This request returns pricing information in XML format, including product codes and their corresponding current prices. It requires the same authentication credentials and certificate setup used in the product data request. This endpoint is essential for keeping your WooCommerce store’s pricing in sync with MSAN’s latest pricing updates.

Get product specifications Curl Request:

To retrieve additional product options or specifications, the MSAN B2B API provides another dedicated endpoint:
https://b2b.msan.hr/B2BService/HTTP/Product/GetProductsSpecification.aspx

Using the same cURL request structure and authentication setup as the previous endpoints, this URL returns detailed specification data in XML format. The response typically includes technical attributes, extended descriptions, and other metadata that can be used to enrich product listings on your WooCommerce store. Incorporating this data helps provide more complete product information for customers, improving the overall shopping experience.

With the combination of these API endpoints—product list, price list, and product specifications—you can fully automate the import and update of products from the MSAN B2B service into your WooCommerce store. By using cURL requests and handling the XML responses properly, your store can stay up to date with the latest product details, pricing, and technical specifications. We’ve implemented this process through a custom WooCommerce plugin tailored for MSAN’s API. If you’re interested in using this plugin or need a custom solution for your store, feel free to contact us for more information or support.

Contact Us Now!

Need any Support?