17 use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory;
23 class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\PdfDocumentsMassAction
70 parent::__construct($context,
$filter);
82 $invoicesCollection = $this->collectionFactory->create()->setOrderFilter([
'in' =>
$collection->getAllIds()]);
83 if (!$invoicesCollection->getSize()) {
84 $this->messageManager->addErrorMessage(
__(
'There are no printable documents related to selected orders.'));
87 $pdf = $this->pdfInvoice->getPdf($invoicesCollection->getItems());
88 $fileContent = [
'type' =>
'string',
'value' => $pdf->render(),
'rm' =>
true];
90 return $this->fileFactory->create(
91 sprintf(
'invoice%s.pdf', $this->dateTime->date(
'Y-m-d_H-i-s')),
93 DirectoryList::VAR_DIR,
massAction(AbstractCollection $collection)
__construct(Context $context, Filter $filter, CollectionFactory $collectionFactory, DateTime $dateTime, FileFactory $fileFactory, Invoice $pdfInvoice)