Skip to content

Commit 2dd2392

Browse files
author
Yu Tang
committed
MAGETWO-28256: Bundle Integration API Refactoring
- Removed duplicate method is_defined from LinkInterface - Check extension attributes fields is not null
1 parent 55841eb commit 2dd2392

File tree

7 files changed

+11
-42
lines changed

7 files changed

+11
-42
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,6 @@ public function getPosition();
8787
*/
8888
public function setPosition($position);
8989

90-
/**
91-
* Get is defined
92-
*
93-
* @return bool|null
94-
*/
95-
public function getIsDefined();
96-
97-
/**
98-
* Set is defined
99-
*
100-
* @param bool $isDefined
101-
* @return $this
102-
*/
103-
public function setIsDefined($isDefined);
104-
10590
/**
10691
* Get is default
10792
*

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements
2121
const KEY_OPTION_ID = 'option_id';
2222
const KEY_QTY = 'qty';
2323
const KEY_POSITION = 'position';
24-
const KEY_IS_DEFINED = 'is_defined';
2524
const KEY_IS_DEFAULT = 'is_default';
2625
const KEY_PRICE = 'price';
2726
const KEY_PRICE_TYPE = 'price_type';
28-
const KEY_CAN_CHANGE_QUANTITY = 'can_change_quantity';
27+
const KEY_CAN_CHANGE_QUANTITY = 'selection_can_change_quantity';
2928
/**#@-*/
3029

3130
/**
@@ -77,14 +76,6 @@ public function getPosition()
7776
return $this->getData(self::KEY_POSITION);
7877
}
7978

80-
/**
81-
* {@inheritdoc}
82-
*/
83-
public function getIsDefined()
84-
{
85-
return $this->getData(self::KEY_IS_DEFINED);
86-
}
87-
8879
/**
8980
* {@inheritdoc}
9081
*/
@@ -161,17 +152,6 @@ public function setPosition($position)
161152
return $this->setData(self::KEY_POSITION, $position);
162153
}
163154

164-
/**
165-
* Set is defined
166-
*
167-
* @param bool $isDefined
168-
* @return $this
169-
*/
170-
public function setIsDefined($isDefined)
171-
{
172-
return $this->setData(self::KEY_IS_DEFINED, $isDefined);
173-
}
174-
175155
/**
176156
* Set is default
177157
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private function buildLink(\Magento\Catalog\Model\Product $selection, \Magento\C
324324
$link->setIsDefault($selection->getIsDefault())
325325
->setId($selection->getSelectionId())
326326
->setQty($selection->getSelectionQty())
327-
->setIsDefined($selection->getSelectionCanChangeQty())
327+
->setCanChangeQuantity($selection->getSelectionCanChangeQty())
328328
->setPrice($selectionPrice)
329329
->setPriceType($selectionPriceType);
330330
return $link;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public function aroundSave(
4646
}
4747

4848
/* @var \Magento\Bundle\Api\Data\OptionInterface[] $options */
49-
$bundleProductOptions = $product->getExtensionAttributes()->getBundleProductOptions();
49+
$extendedAttributes = $product->getExtensionAttributes();
50+
if ($extendedAttributes === null) {
51+
return $result;
52+
}
53+
$bundleProductOptions = $extendedAttributes->getBundleProductOptions();
5054
if ($bundleProductOptions == null) {
5155
return $result;
5256
}

app/code/Magento/Bundle/Model/Product/LinksList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getItems(\Magento\Catalog\Api\Data\ProductInterface $product, $o
6363
$productLink->setIsDefault($selection->getIsDefault())
6464
->setId($selection->getSelectionId())
6565
->setQty($selection->getSelectionQty())
66-
->setIsDefined($selection->getSelectionCanChangeQty())
66+
->setCanChangeQuantity($selection->getSelectionCanChangeQty())
6767
->setPrice($selectionPrice)
6868
->setPriceType($selectionPriceType);
6969
$productLinks[] = $productLink;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function testGetChildren()
193193
->willReturnSelf();
194194
$this->link->expects($this->once())->method('setIsDefault')->willReturnSelf();
195195
$this->link->expects($this->once())->method('setQty')->willReturnSelf();
196-
$this->link->expects($this->once())->method('setIsDefined')->willReturnSelf();
196+
$this->link->expects($this->once())->method('setCanChangeQuantity')->willReturnSelf();
197197
$this->link->expects($this->once())->method('setPrice')->willReturnSelf();
198198
$this->link->expects($this->once())->method('setPriceType')->willReturnSelf();
199199
$this->link->expects($this->once())->method('setId')->willReturnSelf();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public function testGetChildren()
3333
$this->assertArrayHasKey(0, $result);
3434
$this->assertArrayHasKey('option_id', $result[0]);
3535
$this->assertArrayHasKey('is_default', $result[0]);
36-
$this->assertArrayHasKey('is_defined', $result[0]);
36+
$this->assertArrayHasKey('can_change_quantity', $result[0]);
3737
$this->assertArrayHasKey('price', $result[0]);
3838
$this->assertArrayHasKey('price_type', $result[0]);
3939
$this->assertNotNull($result[0]['id']);
4040

41-
unset($result[0]['option_id'], $result[0]['is_default'], $result[0]['is_defined']);
41+
unset($result[0]['option_id'], $result[0]['is_default'], $result[0]['can_change_quantity']);
4242
unset($result[0]['price'], $result[0]['price_type'], $result[0]['id']);
4343

4444
ksort($result[0]);

0 commit comments

Comments
 (0)