Skip to content

Commit 952a8a9

Browse files
committed
MAGETWO-86218: Enable Add to Cart on bundle products when bundle item qty is not User Defined while backorders are allowed
1 parent 1575a5b commit 952a8a9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

dev/tests/integration/testsuite/Magento/Bundle/Model/ProductTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,22 @@ public function testIsSalable(
152152
$bundle = $productRepository->get('bundle-product');
153153

154154
$child = $productRepository->get('simple');
155-
$stockRegistry = $this->objectManager->get(StockRegistryInterface::class);
156-
$childStockItem = $stockRegistry->getStockItem($child->getId());
155+
$childStockItem = $child->getExtensionAttributes()->getStockItem();
157156
$childStockItem->setQty($qty);
158157
$childStockItem->setIsInStock($isInStock);
159158
$childStockItem->setUseConfigManageStock(false);
160159
$childStockItem->setManageStock($manageStock);
161160
$childStockItem->setUseConfigBackorders(false);
162161
$childStockItem->setBackorders($backorders);
163-
$stockRegistry->updateStockItemBySku($child->getSku(), $childStockItem);
162+
$productRepository->save($child);
164163

165-
$linkManagement = $this->objectManager->get(\Magento\Bundle\Api\ProductLinkManagementInterface::class);
166164
foreach ($bundle->getExtensionAttributes()->getBundleProductOptions() as $productOption) {
167165
foreach ($productOption->getProductLinks() as $productLink) {
168166
$productLink->setCanChangeQuantity(0);
169167
$productLink->setQty($selectionQty);
170-
$linkManagement->saveChild($bundle->getSku(), $productLink);
171168
}
172169
}
170+
$productRepository->save($bundle);
173171

174172
$this->assertEquals($isSalable, $bundle->isSalable());
175173
}

0 commit comments

Comments
 (0)