Magento

Add Configurable Products via SOAP/XML-RPC

Icon NetzkollektivBy Dominik Krebs, Managing Director, CTO

The following tutorial will guide you through the whole process of adding Configurable Products using the Magento Core API. The tutorial covers both, the SOAP v1 API usage and the SOAP v2 API usage.

Please note, that the method catalog_product_type_configurable.assign used to combine the configurables with simple products is part of our Magento Core API Extension and not available in Magento natively.

Create a Configurable Product

To create a Configurable Product you need to use the catalog_product.create method. The product type can be specified with the first parameter. In this case you have to use ‘configurable’.

[tabs type=”tabs”]
[tab title=”SOAP v1″ active=”true”]
https://gist.github.com/netzkollektiv/d24b568954dd4ddc9e073db92577c60d
[/tab]
[tab title=”SOAP v2″]
https://gist.github.com/netzkollektiv/afc5e94d1271bf3f983b5c98483c6fef
[/tab]
[/tabs]

Create a Simple Product

Now you have to create all the Simple Products – the variants of the Configurable Product. Every Simple Product corresponds to an attribute combination of the Configurable Product and may be bought by customers by choosing the appropriate options on the product page.

Create product attribute options

Every simple product needs to have its distinct options which can be chosen by customers.

Example: you want to create a product with the attributes color and size. So we need different sizes (e.g. S, M, L, XL, XXL) as well as different colors (e.g. green, yellow, red, brown, black) in the corresponding select-attribute.
To create these options, call the API as shown below:

[tabs type=”tabs”]
[tab title=”SOAP v1″ active=”true”]
https://gist.github.com/netzkollektiv/33e88d7be2724b527682ea5e9e36f9a1
[/tab]
[tab title=”SOAP v2″]
https://gist.github.com/netzkollektiv/4d41fd209efab198b90a0ef97736a108
[/tab]
[/tabs]

To assign the attribute option to the simple product, you need to use the option id (not: the value, e.g. XL) of the previously created option! Now, create the simple products with the option assigned:

[tabs type=”tabs”]
[tab title=”SOAP v1″ active=”true”]
https://gist.github.com/netzkollektiv/98ed89b361bc8c42f5a2256d7e5f9307
[/tab]
[tab title=”SOAP v2″]
https://gist.github.com/netzkollektiv/c075c7fa685a539b65e6d1ad5f334308
[/tab]
[/tabs]

Putting all together

In the last step you need to link all products so that they can be bought via the Configurable Product. The API call is relatively simple. Mandatory are only the product id’s or skus of the Configurable and Simple products. If you want to set surcharges or you want to link only a subset of the configurable attributes, then also specify the other parameters.

[tabs type=”tabs”]
[tab title=”SOAP v1″ active=”true”]
https://gist.github.com/netzkollektiv/a1fd86e52bf2508b79f6cba6e71af8e1
[/tab]
[tab title=”SOAP v2″]
https://gist.github.com/netzkollektiv/51ab5ab6ba7b92bf476c717fb295023b
[/tab]
[/tabs]

A short explanation of all options:

  • configurableProductId: Id or sku of Configurable Product
  • simpleProducts: an array which contains Ids or skus of all Simple Products which should be linked
  • usedAttributes: attributes which should be used to create the Configurable Product
  • labels: a key-value-pair including label and attribute code, to specifiy the title which will be shown at the product page for each attribute
  • prices: an array containing prices per attribut option (as absolut price or percent value)
  • store: by specifying the store you can change the attribute names per store (different languages)


Magento Agentur gesucht?

Sie sind auf der Suche nach einer zuverlässigen Agentur, die sich mit Magento auskennt und Ihnen unkompliziert durch den Online-Shop Alltag hilft? NETZKOLLEKTIV betreut Händler seit über 10 Jahren. Rufen Sie uns an!

Jetzt unverbindlich über mein Projekt sprechen