1111use Magento \Bundle \Api \Data \LinkInterface ;
1212use Magento \Bundle \Api \Data \OptionInterface ;
1313use Magento \Bundle \Api \ProductLinkManagementInterface ;
14- use Magento \Bundle \Api \ProductAddChildrenInterface ;
14+ use Magento \Bundle \Api \ProductLinkManagementAddChildrenInterface ;
1515use Magento \Bundle \Model \Product \Type ;
1616use Magento \Bundle \Model \ResourceModel \Option ;
1717use Magento \Bundle \Model \ResourceModel \Option \Collection ;
@@ -51,7 +51,7 @@ class SaveAction
5151 private $ linkManagement ;
5252
5353 /**
54- * @var ProductAddChildrenInterface
54+ * @var ProductLinkManagementAddChildrenInterface
5555 */
5656 private $ addChildren ;
5757
@@ -61,7 +61,7 @@ class SaveAction
6161 * @param Type $type
6262 * @param ProductLinkManagementInterface $linkManagement
6363 * @param StoreManagerInterface|null $storeManager
64- * @param ProductAddChildrenInterface |null $addChildren
64+ * @param ProductLinkManagementAddChildrenInterface |null $addChildren
6565 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
6666 */
6767 public function __construct (
@@ -70,14 +70,14 @@ public function __construct(
7070 Type $ type ,
7171 ProductLinkManagementInterface $ linkManagement ,
7272 ?StoreManagerInterface $ storeManager = null ,
73- ?ProductAddChildrenInterface $ addChildren = null
73+ ?ProductLinkManagementAddChildrenInterface $ addChildren = null
7474 ) {
7575 $ this ->optionResource = $ optionResource ;
7676 $ this ->metadataPool = $ metadataPool ;
7777 $ this ->type = $ type ;
7878 $ this ->linkManagement = $ linkManagement ;
7979 $ this ->addChildren = $ addChildren ?:
80- ObjectManager::getInstance ()->get (ProductAddChildrenInterface ::class);
80+ ObjectManager::getInstance ()->get (ProductLinkManagementAddChildrenInterface ::class);
8181 }
8282
8383 /**
@@ -153,10 +153,7 @@ private function saveOptionItem(
153153 throw new CouldNotSaveException (__ ("The option couldn't be saved. " ), $ e );
154154 }
155155
156- /** @var LinkInterface $linkedProduct */
157- foreach ($ linksToAdd as $ linkedProduct ) {
158- $ this ->linkManagement ->addChild ($ bundleProduct , $ option ->getOptionId (), $ linkedProduct );
159- }
156+ $ this ->addChildren ->addChildren ($ bundleProduct , (int )$ option ->getOptionId (), $ linksToAdd );
160157 }
161158
162159 /**
0 commit comments