1

This is my first post here, and my first month of learning Magento 2.

I've been able to create configurable and simple products using PHP, but I can't find a way to associate those simple products to a configurable product. The only resource I've found about it is this one.

But still, I couldn't make it work.

Basically I've created a custom product attribute for the sizes (later on I'll manually look into how to do it programmatically) and I have created products so that the end result is that you see one product of which you can choose multiple sizes.

This is just like Magento 2 with sample data. I've learned how to do it manually but I couldn't find out how to do it programmatically with PHP.

Are there any pointers that could help me solve this issue?

marked as duplicate by KAndy, Fabian Schmengler, Raphael at Digital Pianism, Amit Bera, Qaisar Satti Jun 24 '16 at 9:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • the duplicate question referred NOT WORKS, but follow the link in the KAndy answer below. – LucScu Jul 20 '16 at 10:05
1

You need use ConfigurableProductLinks extension attribute for this.

See how Magento developer do it in test fixtures product_configurable.php

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