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

Overriding Invoice pdf
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

Hi, does anyone override sales order pdf invoice ? When I did, Nothing happened.

Please give me advice, thanks…

There are 2 files added :
- local/Hwareh/Sales/etc/config.xml
- local/Hwareh/Sales/Model/Order/Pdf/Shipment.php

Here is my code :
- local/Hwareh/Sales/etc/config.xml

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
sales_order_pdf>
                <
rewrite>
                    <
shipment>Hwareh_Sales_Model_Order_Pdf_Shipment</shipment>
                </
rewrite>
            </
sales_order_pdf>
        </
models>
    </global>
</
config>

- local/Hwareh/Sales/Model/Order/Pdf/Shipment.php

class Hwareh_Sales_Model_Order_Pdf_Shipment extends Mage_Sales_Model_Order_Pdf_Abstract

{

    
public function getPdf($shipments = array()) {
        
echo 'SUCCESS rewriting';
    
}

}
 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

Gottcha
at : etc/config.xml should be

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
sales>
                <
rewrite>
                    <
order_pdf_shipment>Hwareh_Sales_Model_Order_Pdf_Shipment</order_pdf_shipment>
                </
rewrite>
            </
sales>
        </
models>
    </global>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
fenixf
Member
 
Total Posts:  35
Joined:  2008-04-08
 
alkarim - 29 October 2008 01:55 AM

Gottcha
at : etc/config.xml should be

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
sales>
                <
rewrite>
                    <
order_pdf_shipment>Hwareh_Sales_Model_Order_Pdf_Shipment</order_pdf_shipment>
                </
rewrite>
            </
sales>
        </
models>
    </global>
</
config>

Nice!

But do you see the logic? I don’t
I am als trying to rewrite my code but not much succes. only with breadcrumbs with the exampla Fido provided here

Question: Is it possible to do all the rewritings in on config file?

 
Magento Community Magento Community
Magento Community
Magento Community
 
fenixf
Member
 
Total Posts:  35
Joined:  2008-04-08
 

I’m still having problems:

I managed to rewrite both breadcrumbs.php and product.php both located in mage/catalog/block/ But:
Both rewriting are not working at the same time!

If I turn off rewriting of product.php then breadcrumbs.php is rewritten. I put an echo(’tes’) in this file which shows up

If I put rewriting of product.php on, then only product.php is rewritten and the breadcrumbs do not show up at all.

I do the testing on a products page

my configfiles
for breadcrumbs:

<?xml version="1.0"?>
<config>
  <global>
   <
blocks>
        <
catalog>
              <
rewrite>
                 <
breadcrumbs>Fenix_Rewrites_Catalog_Block_Breadcrumbs</breadcrumbs>
            </
rewrite>
           </
catalog>
        </
blocks>           
    </global>
</
config>
for product

<?xml version="1.0"?>
<config>
  <global>
   <
blocks>
        <
catalog>
               <
rewrite>
                <
breadcrumbs>Fenix_Rewrites_Product_Block_Product</breadcrumbs>
            </
rewrite>
           </
catalog>
        </
blocks>           
    </global>
</
config>

I use breadcrumbs here too because something else does not work.

Fenix_Rewrites

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

</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top