2

I want to create products using commerce services resource module. At this moment, I can create a product calling the resource .../product with POST, but It seems that It only creates a product variations, because If I navigate to "manage products" option, I can't see the new product but if I call a GET over resource .../product I can see the new one. Then, I'd tried to create a product using .../node resource, but I always get an error:

"field_product][und][form][commerce_price][und][0][amount": "Price field is required"  

I don't know what is the right JSON structure to create a node with its product variations. Could some one put here an example of the right JSON structure for creating node products?
Thanks.

1 Answer 1

0

I've found the error. Firstable, my drupal commerce installation hasn't product_display content type. I have to add it manually. I don't know why, but It's missing after clean installation. Secondly, the right JSON structure for commerce price section is:

"field_product":{ "und" :  
            {  "form": {
                   "commerce_price": {
                        "und": [ {
                           "amount": "1234.34",
                           "currency_code": "EUR",
                           "data": { "components": [] }
                            } ]
                      },
                   "sku":"eeaafe3231aa"
          }

After this change, I can create products display and I can see it on product manage page. Hope It could be useful for other who has the same problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.