Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Sales
_files
order_with_shipping_and_invoice.php
Go to the documentation of this file.
1
<?php
7
use
Magento\Sales\Model\Order\ShipmentFactory
;
8
9
require
'order.php'
;
10
11
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
12
14
$order
=
$objectManager
->create(\
Magento
\Sales\Model\Order::class)
15
->loadByIncrementId(
'100000001'
);
16
18
$invoiceService
=
$objectManager
->create(\
Magento
\Sales\Api\InvoiceManagementInterface::class);
19
21
$transaction
=
$objectManager
->create(\
Magento
\Framework\DB\Transaction::class);
22
23
$order
->setData(
24
'base_to_global_rate'
,
25
1
26
)->setData(
27
'base_to_order_rate'
,
28
1
29
)->setData(
30
'shipping_amount'
,
31
20
32
)->setData(
33
'base_shipping_amount'
,
34
20
35
);
36
37
$invoice
=
$invoiceService
->prepareInvoice(
$order
);
38
$invoice
->register();
39
40
$order
->setIsInProcess(
true
);
41
42
$items
= [];
43
foreach
(
$order
->getItems() as
$orderItem
) {
44
$items
[
$orderItem
->getId()] =
$orderItem
->getQtyOrdered();
45
}
46
$shipment
=
$objectManager
->get(ShipmentFactory::class)->create(
$order
,
$items
);
47
48
$transaction
->addObject(
$invoice
)->addObject(
$shipment
)->addObject(
$order
)->save();
Magento\Sales\Model\Order\ShipmentFactory
Definition:
ShipmentFactory.php:16
$invoiceService
$invoiceService
Definition:
order_with_shipping_and_invoice.php:18
$orderItem
$orderItem
Definition:
order.php:30
$invoice
$invoice
Definition:
order_with_shipping_and_invoice.php:37
$order
$order
Definition:
order_with_shipping_and_invoice.php:14
Magento
$objectManager
$objectManager
Definition:
order_with_shipping_and_invoice.php:11
$items
$items
Definition:
order_with_shipping_and_invoice.php:42
$transaction
$transaction
Definition:
order_with_shipping_and_invoice.php:21
$shipment
foreach($order->getItems() as $orderItem) $shipment
Definition:
order_with_shipping_and_invoice.php:46
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125