Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Lets see what is going on. As we can see from the url (www.example.com/index.php/admin/sales_invoice/view/invoice_id/[some_id]/) <code>Mage_Adminhtml_Sales_Order_InvoiceController</code>'s <code>view</code> action is executed and this is corresponds to <code>&lt;adminhtml_sales_order_invoice_view&gt;</code> layout (app/design/adminhtml/default/default/layout/sales.xml) node. There we can see this: </p> <pre><code>&lt;adminhtml_sales_order_invoice_view&gt; &lt;reference name="content"&gt; &lt;block type="adminhtml/sales_order_invoice_view" name="sales_invoice_view"&gt; ... </code></pre> <p>We can see there that top block is <code>Mage_Adminhtml_Block_Sales_Order_Invoice_View</code>. There we can see (at the end of <code>__construct()</code> method):</p> <pre><code>if ($this-&gt;getInvoice()-&gt;getId()) { $this-&gt;_addButton('print', array( 'label' =&gt; Mage::helper('sales')-&gt;__('Print'), 'class' =&gt; 'save', 'onclick' =&gt; 'setLocation(\''.$this-&gt;getPrintUrl().'\')' ) ); } </code></pre> <p>and </p> <pre><code>public function getPrintUrl() { return $this-&gt;getUrl('*/*/print', array( 'invoice_id' =&gt; $this-&gt;getInvoice()-&gt;getId() )); } </code></pre> <p>Here we can see that our invoice PDF is created from a <code>print</code> action of current module/controller so lets see <code>Mage_Adminhtml_Sales_Order_InvoiceController</code> again and search for a required action method:</p> <pre><code>/** * Create pdf for current invoice */ public function printAction() { $this-&gt;_initInvoice(); parent::printAction(); } </code></pre> <p>and in parent <code>Mage_Adminhtml_Controller_Sales_Invoice</code>:</p> <pre><code>public function printAction() { if ($invoiceId = $this-&gt;getRequest()-&gt;getParam('invoice_id')) { if ($invoice = Mage::getModel('sales/order_invoice')-&gt;load($invoiceId)) { $pdf = Mage::getModel('sales/order_pdf_invoice')-&gt;getPdf(array($invoice)); $this-&gt;_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')-&gt;date('Y-m-d_H-i-s'). '.pdf', $pdf-&gt;render(), 'application/pdf'); } } else { $this-&gt;_forward('noRoute'); } } </code></pre> <p><strong>As we can see the PDF is created by <code>sales/order_pdf_invoice</code> model (or <code>Mage_Sales_Model_Order_Pdf_Invoice</code> class)</strong>. Inside of a <code>getPdf()</code> method is a call <code>$this-&gt;insertTotals($page, $invoice);</code> which is defined in <code>Mage_Sales_Model_Order_Pdf_Abstract</code> class. <strong>My suggestion is to overwrite <code>Mage_Sales_Model_Order_Pdf_Invoice</code> class and define there a custom <code>insertTotals($page, $invoice)</code> method to achieve what you need.</strong> I decided to give a full picture of the situation to let you decide how to solve this task.</p> <p>Useful link - <a href="http://inchoo.net/ecommerce/magento/how_to_override_magento_model_classes/" rel="nofollow">Overriding a model class in Magento</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload