59 lines
1.6 KiB
PHP
Executable File
59 lines
1.6 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
|
|
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(
|
|
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
|
|
);
|
|
|
|
/** @var $product \Magento\Catalog\Model\Product */
|
|
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
|
|
$product->setTypeId(
|
|
'virtual'
|
|
)->setId(
|
|
1
|
|
)->setAttributeSetId(
|
|
4
|
|
)->setName(
|
|
'Simple Product'
|
|
)->setSku(
|
|
'simple'
|
|
)->setPrice(
|
|
10
|
|
)->setStoreId(
|
|
1
|
|
)->setStockData(
|
|
['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 100]
|
|
)->setVisibility(
|
|
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
|
|
)->setStatus(
|
|
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
|
|
)->save();
|
|
$product->load(1);
|
|
|
|
/** @var $quote \Magento\Quote\Model\Quote */
|
|
$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
|
|
$quoteItem = $quote->setCustomerId(
|
|
1
|
|
)->setStoreId(
|
|
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
|
\Magento\Store\Model\StoreManagerInterface::class
|
|
)->getStore()->getId()
|
|
)->setReservedOrderId(
|
|
'test01'
|
|
)->addProduct(
|
|
$product,
|
|
10
|
|
);
|
|
/** @var $quoteItem \Magento\Quote\Model\Quote\Item */
|
|
$quoteItem->setQty(1);
|
|
$quote->getPayment()->setMethod('checkmo');
|
|
$quote->getBillingAddress();
|
|
$quote->getShippingAddress()->setCollectShippingRates(true);
|
|
$quote->collectTotals();
|
|
$quote->save();
|
|
$quoteItem->setQuote($quote);
|
|
$quoteItem->save();
|