Skip to content

Instantly share code, notes, and snippets.

@vrann
Created August 17, 2017 22:59
Show Gist options
  • Save vrann/d917fabfecc8991ebe13cb15cc4345a0 to your computer and use it in GitHub Desktop.
Save vrann/d917fabfecc8991ebe13cb15cc4345a0 to your computer and use it in GitHub Desktop.
Integration Test to expose an issue with the multiple save of the Quote with the Configurable product
/**
* @magentoDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php
*/
public function testSaveQuoteMultipleTimes()
{
/** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */
$stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class);
$stockItem->load(10, 'product_id');
if (!$stockItem->getProductId()) {
$stockItem->setProductId(1);
}
$stockItem->setUseConfigManageStock(1);
$stockItem->setQty(1);
$stockItem->setIsQtyDecimal(0);
$stockItem->setIsInStock(1);
$stockItem->save();
/** @var \Magento\CatalogInventory\Model\StockRegistryStorage $stockRegistry */
$stockRegistry = Bootstrap::getObjectManager()->get(\Magento\CatalogInventory\Model\StockRegistryStorage::class);
$stockRegistry->removeStockStatus(10);
$stockRegistry->removeStockItem(10);
/** @var \Magento\Quote\Model\Quote $quote */
$quoteObj = Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
$quoteObj->load('test_cart_with_configurable', 'reserved_order_id');
/** @var \Magento\Quote\Api\CartRepositoryInterface $mageQuoteRepository */
$mageQuoteRepository = Bootstrap::getObjectManager()->create(\Magento\Quote\Api\CartRepositoryInterface::class);
$quote = $mageQuoteRepository->get($quoteObj->getId());
$mageQuoteRepository->save($quote);
$mageQuoteRepository->save($quote);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment