Skip to content

Commit 5d5ae03

Browse files
author
Alexey Yakimovich
committed
MAGETWO-91679: Bundled SKUs are being assembled based on the product ID number
- Fixed an issue with incorrect genereation of dynamic SKU for bundle products;
1 parent 547ad4a commit 5d5ae03

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ public function getSku($product)
308308
$selectionIds = $this->serializer->unserialize($customOption->getValue());
309309
if (!empty($selectionIds)) {
310310
$selections = $this->getSelectionsByIds($selectionIds, $product);
311-
foreach ($selections->getItems() as $selection) {
312-
$skuParts[] = $selection->getSku();
311+
foreach ($selectionIds as $selectionId) {
312+
$entity = $selections->getItemByColumnValue('selection_id', $selectionId);
313+
if ($entity->getEntityId()) {
314+
$skuParts[] = $entity->getSku();
315+
}
313316
}
314317
}
315318
}

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ public function testGetSkuWithoutType()
15951595
->disableOriginalConstructor()
15961596
->getMock();
15971597
$selectionItemMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
1598-
->setMethods(['getSku', '__wakeup'])
1598+
->setMethods(['getSku', 'getEntityId', '__wakeup'])
15991599
->disableOriginalConstructor()
16001600
->getMock();
16011601

@@ -1623,9 +1623,12 @@ public function testGetSkuWithoutType()
16231623
->will($this->returnValue($serializeIds));
16241624
$selectionMock = $this->getSelectionsByIdsMock($selectionIds, $productMock, 5, 6);
16251625
$selectionMock->expects(($this->any()))
1626-
->method('getItems')
1627-
->will($this->returnValue([$selectionItemMock]));
1628-
$selectionItemMock->expects($this->any())
1626+
->method('getItemByColumnValue')
1627+
->will($this->returnValue($selectionItemMock));
1628+
$selectionItemMock->expects($this->at(0))
1629+
->method('getEntityId')
1630+
->will($this->returnValue(1));
1631+
$selectionItemMock->expects($this->once())
16291632
->method('getSku')
16301633
->will($this->returnValue($itemSku));
16311634

0 commit comments

Comments
 (0)