firegento / firegento-pdf

Generates nicer and configurable PDF for invoices, creditmemos and shippings in Magento
100 stars 62 forks source link

Can't Add custom Notes on the bottom of the PDF #375

Closed PericlesBogris closed 6 years ago

PericlesBogris commented 6 years ago

I have followed the istructions here : https://github.com/firegento/firegento-pdf/wiki/FAQs

I Create my own module with the following files:

/app/etc/modules/Esignature.xml

<?xml version="1.0"?>
<config>
<modules>
<Mage_Esignature>
<active>true</active>
<codePool>local</codePool>
</Mage_Esignature>
</modules>
</config>

/app/code/local/Mage/Esignature/etc/config.xml

<config>
<modules>
<Mage_Esignature>
<version>0.0.1</version>
</Mage_Esignature>
</modules>

<global>
    <models>
        <Mage_Esignature>
            <class>Mage_Esignature_Model</class>
        </Mage_Esignature>
     </models>

    <events>
        <firegento_pdf_invoice_edit_page>
         <observers>
            <Mage_Esignature>
                <class>Mage_Esignature/observer</class>
                <method>addFancyStuff</method>
            </Mage_Esignature>
         </observers>
        </firegento_pdf_invoice_edit_page>
    </events>
</global>
</config>

/app/code/local/Mage/Esignature/Model/observer.php

<?php
class Mage_Esignature_Observer
{

    /**
     * Add my super fancy stuff
     *
     * @param  Varien_Event_Observer $observer observer object
     *
     * @return $this
     */
    public function addFancyStuff(Varien_Event_Observer $observer)
    {
        $page = $observer->getPage();
        $page->drawText('This is really super fancy!', 100, 100, 'UTF-8');
        return $this;
    }

}

Magento can see the module and its active. But when i print the invoice the custom text dont appear.

I tried to add on config.xml

<models>
        <Mage_Esignature>
            <class>Mage_Esignature_Model</class>
        </Mage_Esignature>
     </models>

as they say on this issue https://github.com/firegento/firegento-pdf/issues/109 but still didnt work

I use Magento 1.9.3

Any help ?

Schrank commented 6 years ago

Hey, thanks for the report.

  1. Don't use Mage as a namespace. It makes it hard to distinguish between core overwrites and custom modules.
  2. https://magento.stackexchange.com/questions/41277/how-to-create-an-new-observer-on-the-event-catalog-product-save-before You are missing the basic config.xml part around
  3. You need a models node to tell magento what Mage_Esignature/observer is, the alternative is to just add the prefix as a string in the class node like Mage_Esignature_Observer http://inchoo.net/magento/creating-an-eav-based-models-in-magento/
Schrank commented 6 years ago

If this doesn't help, tell us (by commenting). But please understand, that we don't earn any money with this module and there is no official support.

PericlesBogris commented 6 years ago

I managed to fixed this with your very helpful comment ! Thank you very much.

I am trying to get from the order lets say the VAT of the customer

<?php
class Esignature_Model_Observer
{

    /**
     * Add my super fancy stuff
     *
     * @param  Varien_Event_Observer $observer observer object
     *
     * @return $this
     */
    public function addFancyStuff(Varien_Event_Observer $observer)
    {
        $customer = Mage::getModel('customer/customer')->load($customerId);
        $vatNumber = $customer->getData('taxvat');

        $page = $observer->getPage();

        $page->drawText($vatNumber, 10, 10, 'UTF-8');
        return $this;

    }

}

In this way nothing appears. I am doing it all wrong ?

Again thank you for helping me so fast

Schrank commented 6 years ago

Check wether the vat id is on the customer or only on the order.

Schrank commented 6 years ago

Oh no, where is the customerId from? You have an empty customer object.

PericlesBogris commented 6 years ago

Yeah i am doing it wrong... I need to pick the Vat (if it have one) , and the price of each product on the order but i cant find a way always crashes or if it creates the PDF its empty... Anyway thanks for helping !

Schrank commented 6 years ago

You need to get the customer from the order, the order should be part of the observer.