Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_configurable_product_last_variation.php
Go to the documentation of this file.
1 <?php
7 require __DIR__ . '/configurable_products.php';
8 
11 
13 $product->setStockData(['use_config_manage_stock' => 1, 'qty' => 1, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
15 
16 $product = $productRepository->getById(20);
17 $product->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]);
19 
21 $quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
23 
27 $attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
28 
29 $request->setData(
30  [
31  'product_id' => $productRepository->get('configurable')->getId(),
32  'selected_configurable_option' => '1',
33  'super_attribute' => [
34  $attribute->getAttributeId() => $attribute->getOptions()[1]->getValue()
35  ],
36  'qty' => '1'
37  ]
38 );
39 
40 $quote->setStoreId(1)
41  ->setIsActive(
42  true
43  )->setIsMultiShipping(
44  false
45  )->setReservedOrderId(
46  'test_order_with_configurable_product'
47  )->setEmail(
49  )->addProduct(
50  $productRepository->get('configurable'),
51  $request
52  );
53 
56  \Magento\Quote\Model\QuoteRepository::class
57 );
58 $quote->collectTotals();
60 
63  \Magento\Checkout\Model\Session::class
64 );
65 $session->setQuoteId($quote->getId());
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60