11
11
use Magento \Bundle \Api \Data \LinkInterface ;
12
12
use Magento \Bundle \Api \Data \OptionInterface ;
13
13
use Magento \Bundle \Api \ProductLinkManagementInterface ;
14
- use Magento \Bundle \Api \ProductAddChildrenInterface ;
14
+ use Magento \Bundle \Api \ProductLinkManagementAddChildrenInterface ;
15
15
use Magento \Bundle \Model \Product \Type ;
16
16
use Magento \Bundle \Model \ResourceModel \Option ;
17
17
use Magento \Bundle \Model \ResourceModel \Option \Collection ;
@@ -51,7 +51,7 @@ class SaveAction
51
51
private $ linkManagement ;
52
52
53
53
/**
54
- * @var ProductAddChildrenInterface
54
+ * @var ProductLinkManagementAddChildrenInterface
55
55
*/
56
56
private $ addChildren ;
57
57
@@ -61,7 +61,7 @@ class SaveAction
61
61
* @param Type $type
62
62
* @param ProductLinkManagementInterface $linkManagement
63
63
* @param StoreManagerInterface|null $storeManager
64
- * @param ProductAddChildrenInterface |null $addChildren
64
+ * @param ProductLinkManagementAddChildrenInterface |null $addChildren
65
65
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
66
66
*/
67
67
public function __construct (
@@ -70,14 +70,14 @@ public function __construct(
70
70
Type $ type ,
71
71
ProductLinkManagementInterface $ linkManagement ,
72
72
?StoreManagerInterface $ storeManager = null ,
73
- ?ProductAddChildrenInterface $ addChildren = null
73
+ ?ProductLinkManagementAddChildrenInterface $ addChildren = null
74
74
) {
75
75
$ this ->optionResource = $ optionResource ;
76
76
$ this ->metadataPool = $ metadataPool ;
77
77
$ this ->type = $ type ;
78
78
$ this ->linkManagement = $ linkManagement ;
79
79
$ this ->addChildren = $ addChildren ?:
80
- ObjectManager::getInstance ()->get (ProductAddChildrenInterface ::class);
80
+ ObjectManager::getInstance ()->get (ProductLinkManagementAddChildrenInterface ::class);
81
81
}
82
82
83
83
/**
@@ -153,10 +153,7 @@ private function saveOptionItem(
153
153
throw new CouldNotSaveException (__ ("The option couldn't be saved. " ), $ e );
154
154
}
155
155
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 );
160
157
}
161
158
162
159
/**
0 commit comments