2
我想創建magento中前300個訂單的pdf。我想要一個功能,在這個功能中,我將獲得前300個訂單,並在PDF中打印它們的圖像(每個訂單都有不同的圖像)。那麼我怎麼能在magento中實現這個功能。有沒有擴展?在magento中創建訂單的累計pdf
我想創建magento中前300個訂單的pdf。我想要一個功能,在這個功能中,我將獲得前300個訂單,並在PDF中打印它們的圖像(每個訂單都有不同的圖像)。那麼我怎麼能在magento中實現這個功能。有沒有擴展?在magento中創建訂單的累計pdf
看看/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
public function pdfinvoicesAction(){
$orderIds = $this->getRequest()->getPost('order_ids');
$flag = false;
if (!empty($orderIds)) {
foreach ($orderIds as $orderId) {
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
->setOrderFilter($orderId)
->load();
if ($invoices->getSize() > 0) {
$flag = true;
if (!isset($pdf)){
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
} else {
$pages = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
$pdf->pages = array_merge ($pdf->pages, $pages->pages);
}
}
}
if ($flag) {
return $this->_prepareDownloadResponse(
'invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
'application/pdf'
);
} else {
$this->_getSession()->addError($this->__('There are no printable documents related to selected orders.'));
$this->_redirect('*/*/');
}
}
$this->_redirect('*/*/');
}
從上面的功能,你可以指定第一個300名訂單ID爲$ orderIds(或修改法師:: getResourceModel(「銷售/ order_invoice_collection拿到第300條記錄)
變化:
public function pdfinvoicesAction(){
$orderIds = $this->getRequest()->getPost('order_ids');
向(像)
public function pdfinvoices($orderIds){
$orderIds = (array) $orderIds; // first 300 record ids
行更改保存的PDF文件
return $this->_prepareDownloadResponse(
'invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
'application/pdf'
);
要
$pdf->render();
// use the order_id for the pdf name like
$pdf->save("{$orderId}.pdf");
看到Error in generated pdf file using zend_pdf under Magento
你也可以刪除$此 - > _重定向('')
Nice R.S.謝謝:) – MJQ
如何使用上面的數據打印PDF?在外部腳本? – Myron