cancel
Showing results for 
Search instead for 
Did you mean: 

Associating a simple product with a configurable product

0 Kudos

Associating a simple product with a configurable product

Feature request from MidnightDesign, posted on GitHub Jun 27, 2016

What is the correct way to associate an existing simple product with an existing configurable product?

I've been struggling with this for a couple of weeks now. I somehow got it to work im 2.0 using the API classes in Magento\ConfigurableProduct\Api, but that's broken in 2.1. The added products don't show up in the configurable's admin page.

I found some blog posts and Stack Overflow questions related to this, but they either don't work or they don't use the API interfaces.

16 Comments
apiuser
New Member

Comment from antboiko, posted on GitHub Jul 05, 2016

Hi @MidnightDesign , please check this https://github.com/magento/magento2/blob/develop/dev/tests/integration/testsuite/Magento/Configurabl... and let me know if it helps.

Thanks, Anton.

apiuser
New Member

Comment from andimov, posted on GitHub Aug 08, 2016

@MidnightDesign Did you check the solution from the previous comment?

apiuser
New Member

Comment from MidnightDesign, posted on GitHub Aug 08, 2016

Not yet. That's very convoluted and it would take some effort to pick out the parts that I actually need and adapt them to my use case.

KCarmichael
Occasional Contributor

I'm experiencing the same issue.  Have you had any success with getting this resolved?  Here is the issue I've submitted: Magento 2.1 REST API configurableProductLinkManagementV1 Associating Simple to Configurable Products....

 

I'm making a call to REST API configurableProductLinkManagementV1. The first simple product is associated correctly. Any simple product after that is not. The error I receive states "option values are not specified". I'm passing in the following JSON:

 

'{"childSKU": "my SKU here"}'

 

I'm running Magento 2.1.0, PHP version 5.6.25-1+deb.sury.org~trusty+1, Apache/2.4.7, Ubuntu Linux 14.04, MySQL 5.6.33-0ubuntu0.14.04.1.

 

Steps to reproduce

  1. I create all of the simple products using catalogProductRepositoryV1.
  2. I then create the configurable product using the same REST API.
  3. Next I add the configurable product options using configurableProductOptionRepositoryV1.
  4. Finally I associate all of the simple products to the configurable product using configurableProductLinkManagementV1.

Expected result

  1. I'm expecting for the configurable product to have its associated simple products.

Actual result

  1. Only the first simple product has been added to the configurable product. No other simple products are added to the configurable product.

What are the correct steps when creating simple/configurable products and associating the products to one another? And is there any where that I can find what the different JSON objects represent? The REST API documentation doesn't give enough detailed information.

KCarmichael
Occasional Contributor

I'm having the same issue.  Please see my issue submission here.  Have you had any success in getting this resolved? 

mayhem1
Contributor

or mine here: lol. many years later.

https://stackoverflow.com/questions/53490721/how-to-add-configurable-products-programmatically-in-ma...

 

Using OptionRepositoryInterface/LinkManagementInterface.  The hangup (for me at least) seems to be when configuring the Options. OptionRepositoryInterface seems to wipe the OptionInterface values array on save with no errors.