I'm a ColdFusion Developer who is new to Magento 2. I'm trying to understand the process of adding simple and configurable products. I'm utilizing the Rest APIs but the documentation is very vague. At first I created configurable products. That process worked fine. I'm not trying to create simple products and associate those to the configurable products using the REST APIs but the JSON provided in the documentation is a bit confusing.
Thanks for any help you guys can provide.
Keith
Solved! Go to Solution.
Hi Sherrie.
I was able to figure it out by making a call to REST API configurableProductLinkManagementV1. Here is the code I used in my ColdFusion function:
<cfargument name="authToken" required="yes">
<cfargument name="parentSKU" required="yes">
<cfargument name="childSKU" required="yes">
<cfset var urlAddress = "" />
<cfset var inputJSON = "" />
<cfset urlAddress = "#Application.MagentoHost#/rest/V1/configurable-products/#arguments.parentSKU#/child">
<cfset inputJSON = '{"childSku": "#arguments.childSKU#"}' />
<cfhttp url="#urlAddress#" method="post" result="resSimpleConfigProduct">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Authorization" value="Bearer #arguments.authToken#" />
<cfhttpparam type="body" value='#inputJSON#' />
</cfhttp>
After doing so, I then made a call to REST API configurableProductOptionRepositoryV1 to add options to the configurable product. Here is the code I used in my ColdFusion function:
<cfargument name="authToken" required="yes">
<cfargument name="sku" required="yes">
<cfargument name="optionJSON" required="yes">
<cfset var urlAddress = "" />
<cfset urlAddress = "#Application.MagentoHost#/rest/V1/configurable-products/#arguments.sku#/options">
<cfhttp url="#urlAddress#" method="post" result="resAddConfigOptions">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Authorization" value="Bearer #arguments.authToken#" />
<cfhttpparam type="body" value='#arguments.optionJSON#' />
</cfhttp>
Thanks for the follow-up!
Hi @KCarmichael, were you able to find what you were looking for here?
Hi Sherrie.
I was able to figure it out by making a call to REST API configurableProductLinkManagementV1. Here is the code I used in my ColdFusion function:
<cfargument name="authToken" required="yes">
<cfargument name="parentSKU" required="yes">
<cfargument name="childSKU" required="yes">
<cfset var urlAddress = "" />
<cfset var inputJSON = "" />
<cfset urlAddress = "#Application.MagentoHost#/rest/V1/configurable-products/#arguments.parentSKU#/child">
<cfset inputJSON = '{"childSku": "#arguments.childSKU#"}' />
<cfhttp url="#urlAddress#" method="post" result="resSimpleConfigProduct">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Authorization" value="Bearer #arguments.authToken#" />
<cfhttpparam type="body" value='#inputJSON#' />
</cfhttp>
After doing so, I then made a call to REST API configurableProductOptionRepositoryV1 to add options to the configurable product. Here is the code I used in my ColdFusion function:
<cfargument name="authToken" required="yes">
<cfargument name="sku" required="yes">
<cfargument name="optionJSON" required="yes">
<cfset var urlAddress = "" />
<cfset urlAddress = "#Application.MagentoHost#/rest/V1/configurable-products/#arguments.sku#/options">
<cfhttp url="#urlAddress#" method="post" result="resAddConfigOptions">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Authorization" value="Bearer #arguments.authToken#" />
<cfhttpparam type="body" value='#arguments.optionJSON#' />
</cfhttp>
Thanks for the follow-up!
Glad you got it sorted @KCarmichael, thanks for reporting back with the solution!
Hi!
I work with Magento 2.
I don't understand respectively can not use this code, because i am not a programmer.
Can you explain it to me in a "normal lenguage"?
My question is: How can connect already existing simple products with a configurable parent product (like in it works in Magento 1) ??? I know Magento 2 is different...
I know how it works to create and connect NEW simples via a config. parent product. But this not my question. Is there such a function for connecting existing simples with config. parents?
Can you help me, please?
Maybe i should give this code to our programmer... perhaps he can use it?! But finally, i still can't work with Magento 2, if myself don't know how it works!
Hi again!
I think this code isn't the right one for me...
Because it relates to creating and connecting NEW simple products via a configurable parent product. It seems to me that the code, which i need, doesn't exist respectively no one has an answer for me. In my opinion that is because Magento 2 isn't a ready-programmed system!!!
I need a programmer who can programm this code for me!
Is there anyone who can do this???
Magento 2 is so new that no one knows this answer?!
Hey.
I'm not a programmer so I would like to know if you got an answer to your following question :
"What is the best practice for creating configurable products? Do I create the configurable product first or the simple product?"
Thank you :-)
Steven
Here's a clear guide how to achieve that: https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/plan-product.html