Introduction

This article describes how to create or update products in WooCommerce in one integration.

 

Step 1: Create an outgoing configuration

  • Navigate to “Connections” in the menu and select “Outgoing”.
  • Create a new outgoing configuration to setup the process of creating and updating WooCommerce products.
  • Insert a name in the “name” field.
    1. For example: “WooCommerce – Products – Upsert a product”.
  • Under “Publisher” select “WooCommerce - Product - Create or update Product”.
  • Under “WooCommerce HTTP client” select the HTTP client that you created during the initial setup.
  • Click “Add entity transformer” and select “WooCommerce - Product - Restructure from Alumio product”.
    1. This transformer converts data from the Alumio product schema to a format that WooCommerce understands.

Step 2: Create a route

Next you’ll create a route to bind the incoming configuration to the outgoing configuration. In the route, you’ll need to select the outgoing configuration you created in the previous steps.

On the following links, you can find more information about creating routes and incoming configurations and subscribers.

 

Step 3: Get the product ID from WooCommerce by looking up a SKU

At this step, you need to check if the SKU already exists in the WordPress website, to either use the existing product ID or to create a new product.

  • In the route, click “Add entity transformer” and select the “WooCommerce - Product - Find Product by SKU” transformer.
  • Under “WooCommerce HTTP client” select the HTTP client that you created during the initial setup.
  • Under “Sku”, specify the path where the product’s SKU is stored within the data, using the “&{}” notation.
    1. For example: “&{sku}” or “&{product.sku}”.

  • Click “Add entity transformer” at the bottom of the page and select the “Data, transform data using mappers and conditions” transformer.
  • Click “Add data transformer” and select “Conditional transformer”
  • Within the conditional transformer, click “Add data transformer” and select “List mapper”
  • Under “Accessor”, select “Key accessor”
  • Click “Add mappers” and select “List: Extend with supplied data”
  • Under “Array”, fill in the following template:
{
   "identifier": "&{WooCommerceProduct[0].id}"
}


Within the conditional transformer, click “Add filter” and select “Value condition”.

  • Under “Accessor” select “Pattern accessor”.
  • Under “Pattern” insert “WooCommerceProduct”.
  • Select “Add conditions” and select “Is not empty”.

 

Additional information

There’s also a transformer available (“WooCommerce - Product - Create or update Product with sending data”) that has the same functionalities as this outgoing configuration. You can use this in case you like to add additional steps in your route after you created the product. You can combine the SKU check in step 3 with this transformer.

It’s currently not possible to update an individual variant.

You could use the “WooCommerce - Product - Find Product by SKU” transformer to get product data based on SKU.

This outgoing configuration uses the Alumio product schema.

 

That’s it!

You should now be able to create and update products in WooCommerce in one route!