1

Programmatically:
How to associate simple products to the configurable product without creating configurable product, because it exists.

1

I found the solution:

Load product configurable by ID:

$associatedProductIds = [2060,2061,2062,2063];//Simple Product ids array
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load(2046); // Load Configurable Product
$product->setAssociatedProductIds($associatedProductIds);
$product->save();

Load product configurable by SKU:

$associatedProductIds = [2060,2061,2062,2063];//Simple Product ids array
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $this->objectManager->create($this->mProduct, null)->getSku('24-WG085_Group'); // Load Configurable Product
$product->setAssociatedProductIds($associatedProductIds);
$product->save();
  • 1
    Do you have solution for grouped product ? like how to assign simple product to grouped product programatically – Manthan Dave Sep 13 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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