Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Adding new PDF Model in Mage/Sales/Order/Pdf and access it with Mage::getModel()
 
drdre3
Jr. Member
 
Total Posts:  28
Joined:  2009-02-09
 

Hello

I want to add a new PDF Class called “ Mage_Sales_Model_Order_Pdf_Ordermail “. (Like Mage_Sales_Model_Order_Pdf_Invoice)
This class is stored in the file Ordermail.php in Mage/Sales/Order/Pdf.

This class should be the template for a pdf which will be added to the Order Email the customers gets after placing his order.

But now my problem:

How can I access this class??

to generate the invoice pdf you can simply use “Mage::getModel(’sales/order_pdf_invoice’)->getPdf(array($this))”

when i try to use the Mage::getModel() function for my class ("Mage::getModel(’sales/order_pdf_orderemail’)")
I get an error.
So the question is how the register my new class “Mage_Sales_Model_Order_Pdf_Ordermail” for the Mage::getModel() method

 
Magento Community Magento Community
Magento Community
Magento Community
 
drdre3
Jr. Member
 
Total Posts:  28
Joined:  2009-02-09
 

okay i figured out how to use my class via Mage::getModel() but this solution is dirty. To use my class i can simply call Mage::getModel(’Mycompany_Mymodule_Sales_Order_Pdf_Ordermail’)->getPdf(array($this))

 
Magento Community Magento Community
Magento Community
Magento Community
 
mChelevich
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-03-31
 

You can write down to your config.xml these lines:

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
mycustommodule>
                <class>
Mycompany_Mymodule_Model</class>
            </
mycustommodule>
        </
models>
    </global>
</
config>
place this xml into /app/code/local/Mycompany/Mymodule/etc/ folder
place your Ordermail.php into /app/code/local/Mycompany/Mymodule/Model/ folder
then you can get the model by call Mage::getModel(’mycustommodule/ordermail’)

p.s. don’t forget to create your module description in /app/etc/modules/Mycompany_Mymodule.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Mycompany_Mymodule>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Mycompany_Mymodule>
    </
modules>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

http://www.magentocommerce.com/boards/viewthread/10762/P15/#t134738

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top