8
8
use Magento \Bundle \Api \ProductOptionRepositoryInterface as OptionRepository ;
9
9
use Magento \Bundle \Api \ProductLinkManagementInterface ;
10
10
use Magento \Framework \EntityManager \Operation \ExtensionInterface ;
11
+ use Magento \Catalog \Api \Data \ProductInterface ;
11
12
12
13
/**
13
14
* Class SaveHandler
@@ -39,7 +40,7 @@ public function __construct(
39
40
/**
40
41
* @param object $entity
41
42
* @param array $arguments
42
- * @return \Magento\Catalog\Api\Data\ ProductInterface|object
43
+ * @return ProductInterface|object
43
44
* @throws \Magento\Framework\Exception\NoSuchEntityException
44
45
* @throws \Magento\Framework\Exception\InputException
45
46
* @throws \Magento\Framework\Exception\CouldNotSaveException
@@ -65,7 +66,7 @@ public function execute($entity, $arguments = [])
65
66
66
67
if (!$ entity ->getCopyFromView ()) {
67
68
$ this ->processRemovedOptions ($ entity ->getSku (), $ existingOptionsIds , $ optionIds );
68
- $ this ->processExistedOptions ($ entity ->getSku (), $ existingOptionsIds , $ optionIds );
69
+ $ this ->processExistingOptions ($ entity ->getSku (), $ existingOptionsIds , $ optionIds );
69
70
70
71
$ newOptionsIds = array_diff ($ optionIds , $ existingOptionsIds );
71
72
$ this ->saveOptions ($ entity , $ options , $ newOptionsIds );
@@ -97,14 +98,14 @@ protected function removeOptionLinks($entitySku, $option)
97
98
/**
98
99
* Perform save for all options entities
99
100
*
100
- * @param object $entity
101
+ * @param ProductInterface $entity
101
102
* @param array $options
102
103
* @param array $newOptionsIds
103
104
* @throws \Magento\Framework\Exception\CouldNotSaveException
104
105
* @throws \Magento\Framework\Exception\InputException
105
106
* @return void
106
107
*/
107
- private function saveOptions ($ entity , array $ options , array $ newOptionsIds = [])
108
+ private function saveOptions (ProductInterface $ entity , array $ options , array $ newOptionsIds = [])
108
109
{
109
110
foreach ($ options as $ option ) {
110
111
if (in_array ($ option ->getOptionId (), $ newOptionsIds , true )) {
@@ -158,7 +159,7 @@ private function processRemovedOptions($entitySku, array $existingOptionsIds, ar
158
159
}
159
160
160
161
/**
161
- * Removes option links for existed options
162
+ * Removes option links for existing options
162
163
*
163
164
* @param string $entitySku
164
165
* @param array $existingOptionsIds
@@ -167,7 +168,7 @@ private function processRemovedOptions($entitySku, array $existingOptionsIds, ar
167
168
* @throws \Magento\Framework\Exception\InputException
168
169
* @return void
169
170
*/
170
- private function processExistedOptions ($ entitySku , array $ existingOptionsIds , array $ optionIds )
171
+ private function processExistingOptions ($ entitySku , array $ existingOptionsIds , array $ optionIds )
171
172
{
172
173
foreach (array_intersect ($ optionIds , $ existingOptionsIds ) as $ optionId ) {
173
174
$ option = $ this ->optionRepository ->get ($ entitySku , $ optionId );
0 commit comments