Skip to content

Commit 4e118d2

Browse files
author
Yu Tang
committed
MAGETWO-28256: Bundle Integration API Refactoring
- Fix bugs
1 parent ad5dee3 commit 4e118d2

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public function getChildren($productSku, $optionId = null);
3333
public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct);
3434

3535
/**
36-
* @param string $sku
36+
* @param string $productSku
3737
* @param \Magento\Bundle\Api\Data\LinkInterface $linkedProduct
3838
* @throws \Magento\Framework\Exception\NoSuchEntityException
3939
* @throws \Magento\Framework\Exception\CouldNotSaveException
4040
* @throws \Magento\Framework\Exception\InputException
4141
* @return bool
4242
*/
4343
public function saveChild(
44-
$sku,
44+
$productSku,
4545
\Magento\Bundle\Api\Data\LinkInterface $linkedProduct
4646
);
4747

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\L
111111
* @SuppressWarnings(PHPMD.NPathComplexity)
112112
*/
113113
public function saveChild(
114-
$sku,
114+
$productSku,
115115
\Magento\Bundle\Api\Data\LinkInterface $linkedProduct
116116
) {
117-
$product = $this->productRepository->get($sku);
117+
$product = $this->productRepository->get($productSku);
118118
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
119119
throw new InputException(
120120
__('Product with specified sku: "%1" is not a bundle product', [$product->getSku()])

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ public function save(
178178
}
179179
} else {
180180
$optionCollection = $this->type->getOptionsCollection($product);
181-
$optionCollection->setIdFilter($option->getOptionId());
182181

183182
/** @var \Magento\Bundle\Model\Option $existingOption */
184183
$existingOption = $optionCollection->getItemById($option->getOptionId());

app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ public function testUpdateIfOptionDoesNotExist()
335335
->willReturn($optCollectionMock);
336336

337337
$existingOptionMock = $this->getMock('\Magento\Bundle\Model\Option', ['getOptionId'], [], '', false);
338-
$optCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf();
339338
$optCollectionMock->expects($this->once())->method('getItemById')
340339
->with($optionId)
341340
->willReturn($existingOptionMock);
@@ -407,7 +406,6 @@ public function testSaveExistingOption()
407406
'',
408407
false
409408
);
410-
$optCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf();
411409
$optCollectionMock->expects($this->once())->method('getItemById')
412410
->with($optionId)
413411
->willReturn($existingOptionMock);
@@ -479,7 +477,6 @@ public function testSaveExistingOptionNoSuchOption()
479477
'',
480478
false
481479
);
482-
$optCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf();
483480
$optCollectionMock->expects($this->once())->method('getItemById')
484481
->with($optionId)
485482
->willReturn($existingOptionMock);

app/code/Magento/Bundle/etc/webapi.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<resource ref="Magento_Catalog::products"/>
1414
</resources>
1515
</route>
16-
<route url="/V1/bundle-products/:sku/links" method="PUT">
16+
<route url="/V1/bundle-products/:productSku/links" method="PUT">
1717
<service class="Magento\Bundle\Api\ProductLinkManagementInterface" method="saveChild"/>
1818
<resources>
1919
<resource ref="Magento_Catalog::products"/>

dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public function testSaveChild()
111111
*/
112112
private function saveChild($productSku, $linkedProduct)
113113
{
114-
$resourcePath = self::RESOURCE_PATH . '/:sku/links';
114+
$resourcePath = self::RESOURCE_PATH . '/:productSku/links';
115115
$serviceInfo = [
116116
'rest' => [
117117
'resourcePath' => str_replace(
118-
[':sku'],
118+
[':productSku'],
119119
[$productSku],
120120
$resourcePath
121121
),
@@ -129,7 +129,7 @@ private function saveChild($productSku, $linkedProduct)
129129
];
130130
return $this->_webApiCall(
131131
$serviceInfo,
132-
['sku' => $productSku, 'linkedProduct' => $linkedProduct]
132+
['productSku' => $productSku, 'linkedProduct' => $linkedProduct]
133133
);
134134
}
135135

0 commit comments

Comments
 (0)