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
module-sales
Model
Order
InvoiceDocumentFactory.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Sales\Model\Order
;
8
9
use
Magento\Sales\Api\Data\InvoiceCommentCreationInterface
;
10
use
Magento\Sales\Api\Data\InvoiceCreationArgumentsInterface
;
11
use
Magento\Sales\Api\Data\InvoiceInterface
;
12
use
Magento\Sales\Api\Data\InvoiceItemCreationInterface
;
13
use
Magento\Sales\Api\Data\OrderInterface
;
14
use
Magento\Sales\Model\Service\InvoiceService
;
15
22
class
InvoiceDocumentFactory
23
{
27
private
$invoiceService;
28
33
public
function
__construct
(
34
InvoiceService
$invoiceService
35
) {
36
$this->invoiceService =
$invoiceService
;
37
}
38
49
public
function
create
(
50
OrderInterface
$order
,
51
$items
= [],
52
InvoiceCommentCreationInterface
$comment =
null
,
53
$appendComment =
false
,
54
InvoiceCreationArgumentsInterface
$arguments
=
null
55
) {
56
$invoiceItems = $this->itemsToArray(
$items
);
57
$invoice
= $this->invoiceService->prepareInvoice(
$order
, $invoiceItems);
58
59
if
($comment) {
60
$invoice
->addComment(
61
$comment->getComment(),
62
$appendComment,
63
$comment->getIsVisibleOnFront()
64
);
65
}
66
67
return
$invoice
;
68
}
69
76
private
function
itemsToArray(
$items
= [])
77
{
78
$invoiceItems = [];
79
foreach
(
$items
as
$item
) {
80
$invoiceItems[
$item
->getOrderItemId()] =
$item
->getQty();
81
}
82
return
$invoiceItems;
83
}
84
}
Magento\Sales\Model\Order\InvoiceDocumentFactory\__construct
__construct(InvoiceService $invoiceService)
Definition:
InvoiceDocumentFactory.php:33
Magento\Sales\Model\Order\InvoiceDocumentFactory
Definition:
InvoiceDocumentFactory.php:22
Magento\Sales\Api\Data\InvoiceItemCreationInterface
Definition:
InvoiceItemCreationInterface.php:19
Magento\Sales\Model\Order
Magento\Sales\Api\Data\InvoiceInterface
Definition:
InvoiceInterface.php:15
$order
$order
Definition:
order.php:55
Magento\Sales\Model\Service\InvoiceService
Definition:
InvoiceService.php:14
$item
$item
Definition:
partial_invoice.php:27
Magento\Sales\Api\Data\OrderInterface
Definition:
OrderInterface.php:17
$invoice
$invoice
Definition:
partial_invoice.php:22
$invoiceService
$invoiceService
Definition:
partial_invoice.php:21
$arguments
$arguments
Definition:
final_price.phtml:24
Magento\Sales\Api\Data\InvoiceCommentCreationInterface
Definition:
InvoiceCommentCreationInterface.php:17
Magento\Sales\Api\Data\InvoiceCreationArgumentsInterface
Definition:
InvoiceCreationArgumentsInterface.php:14
Magento\Sales\Model\Order\InvoiceDocumentFactory\create
create(OrderInterface $order, $items=[], InvoiceCommentCreationInterface $comment=null, $appendComment=false, InvoiceCreationArgumentsInterface $arguments=null)
Definition:
InvoiceDocumentFactory.php:49
$items
$items
Definition:
order_rollback.php:21