Attempt to build a child product with an SKU that is already in use


#1

Question transferred from the moltin hub slack channel.

Hi guys !
I am trying to build my child product by using the build url : https://api.moltin.com/v2/products/bc82386e-40b5-4fd2-83fd-628e47a28419/build

The thing is each time I request the url I have this error:

{"errors":
  [
    {
      "status":409,
      "detail":"Attempt to build a child product with an SKU that is already in use."
    }
  ]
}

Does it mean that I need to remove all my child products from the store before calling to build url ?

PS: I use a sku_builder modifier


#2

As you might already be aware, we use your configured variations, options & modifiers to generate a matrix of child products. The one stipulation we put in place is that each child product must have a unique slug and sku. Right now this means that you must add in a slug_* and a sku_* modifier for every variation you add.

If any of the child products that would be generated had a sku or slug that would clash with an existing slug or sku, or if any of the generated child products would clash with each other, then you’ll receive the “Attempt to build a child product with an SKU that is already in use.” error.

To fix this, we need to look at the child products that would be generated when you hit the /build endpoint. Using the sku_builder modifier means we’ll replace parts of the base sku with the new values.

Base Sku: BAT-{SIZE}-{DESIGN}

Variations (options)

  • Size (S, M)
  • Design (BEA, BIM, MAR, ROC)

Generated matrix

  • BAT-S-BEA
  • BAT-M-BEA
  • BAT-S-BIM
  • BAT-M-BIM
  • BAT-S-MAR
  • BAT-M-MAR
  • BAT-S-ROC
  • BAT-M-ROC

In this case, your variation/option/modifier setup looks correct so this could be a bug on our end. We’ll investigate and get the issue patched.