Skip to content

Commit 99db07c

Browse files
author
cspruiell
committed
MAGETWO-55126: [Backport] [API] Can not link simple product to configurable one - for 2.1.x
- added concrete implementation of setAssociatedProductIds
1 parent 86e5124 commit 99db07c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* @method Product setHasError(bool $value)
2323
* @method \Magento\Catalog\Model\ResourceModel\Product getResource()
2424
* @method null|bool getHasError()
25-
* @method Product setAssociatedProductIds(array $productIds)
2625
* @method array getAssociatedProductIds()
2726
* @method Product setNewVariationsAttributeSetId(int $value)
2827
* @method int getNewVariationsAttributeSetId()
@@ -2609,4 +2608,13 @@ private function getMediaGalleryProcessor()
26092608
}
26102609
return $this->mediaGalleryProcessor;
26112610
}
2611+
2612+
/**
2613+
* Set the associated products
2614+
* @param array $productIds
2615+
*/
2616+
public function setAssociatedProductIds(array $productIds)
2617+
{
2618+
$this->getExtensionAttributes()->setConfigurableProductLinks($productIds);
2619+
}
26122620
}

app/code/Magento/ConfigurableProduct/Model/LinkManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function removeChild($sku, $childSku)
132132
if (count($options) == count($ids)) {
133133
throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
134134
}
135-
$product->addData(['associated_product_ids' => $ids]);
135+
$product->setAssociatedProductIds($ids);
136136
$product->save();
137137
return true;
138138
}

0 commit comments

Comments
 (0)