Skip to content

Commit 6d0f88b

Browse files
author
Yu Tang
committed
MAGETWO-28256: Bundle Integration API Refactoring
- Added api-functional tests and fixed bugs
1 parent 60847e4 commit 6d0f88b

File tree

8 files changed

+422
-33
lines changed

8 files changed

+422
-33
lines changed

app/code/Magento/Bundle/Api/Data/LinkInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
interface LinkInterface extends \Magento\Framework\Api\ExtensibleDataInterface
1111
{
12+
const PRICE_TYPE_FIXED = 0;
13+
const PRICE_TYPE_PERCENT = 1;
14+
1215
/**
1316
* Get the identifier
1417
*

app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@ class BundleSaveOptions
1414
*/
1515
protected $optionRepository;
1616

17+
/**
18+
* @var \Magento\Catalog\Api\Data\ProductInterfaceFactory
19+
*/
20+
protected $productInterfaceFactory;
21+
1722
/**
1823
* @param \Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository
1924
*/
20-
public function __construct(\Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository)
21-
{
25+
public function __construct(
26+
\Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository,
27+
\Magento\Catalog\Api\Data\ProductInterfaceFactory $productInterfaceFactory
28+
) {
2229
$this->optionRepository = $optionRepository;
30+
$this->productInterfaceFactory = $productInterfaceFactory;
2331
}
2432

2533
/**
@@ -72,6 +80,7 @@ public function aroundSave(
7280
foreach ($optionIdsToDelete as $optionId) {
7381
$this->optionRepository->delete($existingOptionsMap[$optionId]);
7482
}
75-
return $result;
83+
$product = $this->productInterfaceFactory->create()->setSku($result->getSku());
84+
return $subject->save($product);
7685
}
7786
}

app/code/Magento/Bundle/Model/Source/Option/Selection/Price/Type.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Bundle\Model\Source\Option\Selection\Price;
77

8+
use Magento\Bundle\Api\Data\LinkInterface;
9+
810
/**
911
* Extended Attributes Source Model
1012
*
@@ -17,6 +19,9 @@ class Type implements \Magento\Framework\Option\ArrayInterface
1719
*/
1820
public function toOptionArray()
1921
{
20-
return [['value' => '0', 'label' => __('Fixed')], ['value' => '1', 'label' => __('Percent')]];
22+
return [
23+
['value' => LinkInterface::PRICE_TYPE_FIXED, 'label' => __('Fixed')],
24+
['value' => LinkInterface::PRICE_TYPE_PERCENT, 'label' => __('Percent')]
25+
];
2126
}
2227
}

app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public function testAroundLoadIfProductTypeNotBundle()
6060

6161
public function testAroundLoad()
6262
{
63-
$this->markTestSkipped('MAGETWO-34577');
6463
$productMock = $this->getMock(
6564
'\Magento\Catalog\Model\Product',
6665
['getTypeId', 'setExtensionAttributes'],

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd">
99
<custom_attributes for="Magento\Catalog\Api\Data\ProductInterface">
1010
<attribute code="bundle_product_options" type="Magento\Bundle\Api\Data\OptionInterface[]" />
11-
<attribute code="price_type" type="integer" />
12-
<attribute code="price_view" type="string" />
1311
</custom_attributes>
1412
</config>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function __construct(
6464
public function initialize(\Magento\Catalog\Model\Product $product)
6565
{
6666
$productData = $this->request->getPost('product');
67+
unset($productData['custom_attributes']);
68+
unset($productData['extension_attributes']);
6769

6870
if ($productData) {
6971
$stockData = isset($productData['stock_data']) ? $productData['stock_data'] : [];

0 commit comments

Comments
 (0)