I can’t find any information how to create a product with a price for a default variant via the REST API with a single request. I only know how to do this with two requests. First create a product and then update a price of the default variant. So I want to know if it is even possible to do this with a single request?
Topic summary
Goal: create a product with a price in a single REST API request rather than two (create product, then update price).
Key update/solution:
- It is possible in one call by including a variants array in the product creation payload.
- Example: ‘variants’ => [[‘price’ => 22.00]] sets the price on the default variant during creation.
- Central detail: the code snippet showing the variants array is essential to understanding the solution.
Implications clarified/asked:
- This approach implies the “parent” (configurable) product itself doesn’t carry a price; pricing lives on at least one variant (e.g., the default variant).
Open questions (unanswered):
- Must every parent product be created without a price and have at least one variant to carry pricing?
- Is structuring products this way (parent + variant(s) for pricing) the most efficient approach?
Status: The original issue (single-request creation with price) is resolved with a concrete method. Follow-up questions about product structure efficiency remain open.
Forget it, I figured it out myself.
Just provide an array of variants in the request body when creating a product as shown below
'variants' => [['price' => 22.00]],
Hey @layerok ,
In that way we have to create parent products with no price details and on each parent product we have to assign the at least one variant product, is that right?
Is this also the most efficient way to structure product details?
Thanks
Yours sincerely,
Dimitris Goudis