Как создать PDF-файл счета-фактуры на странице оформления заказа magento 1.9.1.0?


Мне нужно создать PDF-файл счета-фактуры на странице оформления заказа. Способ оплаты Банковский перевод для индийского клиента. Есть какие-нибудь идеи по этому поводу?

Страница успеха:- /приложение/дизайн/интерфейс/темы/по умолчанию/шаблон/оформление заказа/успех.phtml:-

<div >
<h1><?php #echo $this->__('Your order will be delivered over email shortly.') ?></h1>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('success_page')->toHtml() ?></div><?php echo $this->getMessagesBlock()->toHtml() ?><h2 class="sub-title"><?php #echo $this->__('Thank you for your purchase!') ?></h2><?php if ($this->getOrderId()):?><?php if ($this->getCanViewOrder()) :?> <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p><?php  else :?>  <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p><?php endif;?> <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p><?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
<p> <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
    <?php echo $this->getChildHtml() ?>
    <a href="<?php echo $this->getUrl('invoice/index/print', array('invoice_id' => $_invoice->getId())); ?>">Download Pdf</a>
</p><?php endif;?><?php endif;?><?php if ($this->getAgreementRefId()): ?>   <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()),$this->escapeHtml($this->getAgreementRefId())))?></p><?php endif;?><?php if ($profiles = $this->getRecurringProfiles()):?><p><?php echo $this->__('Your recurring payment profiles:'); ?></p><ul class="disc"><?php foreach($profiles as $profile):?><?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
<li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li><?php endforeach;?></ul><?php endif;?><div class="buttons-set"><button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button></div> 
Author: Vijayakumar.V, 2018-08-06

1 answers

Вам необходимо создать наблюдателя при размещенном заказе, а затем указать одно условие для вашего способа оплаты и создать соответствующий счет-фактуру с помощью кода.

Пожалуйста, ознакомьтесь с приведенной ниже ссылкой, которая делает в точности то же самое, что вы хотите. Вам нужно только получить PDF-файл счета-фактуры.

Https://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/

Обновлено для генерации PDF:

Обновите вас config.xml как ниже:

App/code/community/Atwix/Orderhook/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Atwix_Orderhook>
            <version>1.0</version>
        </Atwix_Orderhook>
    </modules>
    <!-- Added by Sukumar -->
    <frontend>
       <routers>
          <invoice_print>
              <use>standard</use>
              <args>
                 <module>Atwix_Orderhook</module>
                 <frontName>invoice</frontName>
              </args>
           </invoice_print>
       </routers>
    </frontend>
    <!-- Added by Sukumar -->
    <global>
        <models>            
            <orderhook>
                <class>Atwix_Orderhook_Model</class>
            </orderhook>
        </models>
        <events>
            <sales_order_place_after>
                <observers>
                    <auto_invoice_order>
                        <type>singleton</type>
                        <class>Atwix_Orderhook_Model_Observer</class>
                        <method>implementOrderStatus</method>
                    </auto_invoice_order>
                </observers>
            </sales_order_place_after>
        </events>
    </global>
</config>

Создать IndexController.php по нижеприведенному пути:

App/code/community/Atwix/Orderhook/controllers/IndexController.php

<?php
class Atwix_Orderhook_IndexController extends Mage_Core_Controller_Front_Action
{
  public function printAction()
    {
        if ($invoiceId = $this->getRequest()->getParam('invoice_id')) {
            if ($invoice = Mage::getModel('sales/order_invoice')->load($invoiceId)) {
                $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
            $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
                '.pdf', $pdf->render(), 'application/pdf');
            }
        }
        else {
            $this->_forward('noRoute');
        }
    }
}

И добавьте приведенный ниже код для загрузки PDF, где бы вы ни хотели:

<a href="<?php echo $this->getUrl('invoice/index/print', array('invoice_id' => $_invoice->getId())); ?>">Download Pdf</a>

Добавьте приведенный ниже код к вашему успеху.phtml

<?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); ?>
<?php $invoiceCollection = $order->getInvoiceCollection(); ?>
<?php foreach($invoiceCollection as $invoice): ?>
    <a href="<?php echo $this->getUrl('invoice/index/print', array('invoice_id' => $invoice->getId())); ?>">Download Pdf</a>
<?php endforeach; ?>
 2
Author: Sukumar Gorai, 2018-08-06 14:04:19