Product variations options

php
products
variations

#1

I am struggling to understand how variations really work. For below I use the iPad Mini 4 example.

I understand from the documentation https://docs.moltin.com/inventory/product/modifiers and the blog post https://www.moltin.com/blog/2017/06/introducing-variations-options-modifiers/ that you

  1. Create a variation (which returns, among others, the variation ID)
    $storedVariation = $moltin->variations->create([ "type" => "product-variation", "name" => $variationName ])->data();

  2. Create a variation option
    $option = $moltin->variationOptions->create([ 'type' => 'product-variation-option', 'name' => "blue", 'description' => "blue colour" ])->data();

  3. Link the variation option to the variation
    $moltin->variations->createRelationships($storedVariation->id, 'variation-options', [$option->id]);

Above query (2) unfortunately does not work for me (I receive a 404 error). According to your blog “it doesn’t really make sense for an option to exist outside the context of a variation”. I assume therefore the CURL request on your blog includes the variation ID. This is however not included in the create option query in the PHP SDK. If I look at the PHP SDK file changes on Github, the function createOption (which included the ID) was depreciated.

Any thoughts on how to solve this?


#2

Hi @andre, we made a small change to the way that variations are handled on the API and that means they’re not fully supported on the SDK at the moment. We’ll be making some changes to the SDK to bring the functionality back soon and I’ll post here once it is released…


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.