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

[SOLVED] overwriting app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php does not work. 
 
symmetrics_bl
Member
 
Avatar
Total Posts:  58
Joined:  2008-01-07
Hannover
 

Hi everybody,

I’m trying to overwrite the class app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php. Sadly it does not seem to work and I don’t see what I’m doing wrong. I really appreciate any help - thanks.

app/etc/modules/Symmetrics_Sales.xml

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

module folder structure:

app
    code
        local
            Symmetrics
                Sales
                    etc
                        config
.xml
                    Model
                        Order
                            Pdf
                                Shipment
.php

app/code/local/Symmetrics/Sales/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Symmetrics_Sales>
            <
version>
                
0.1.0
            
</version>
        </
Symmetrics_Sales>
    </
modules>
    
    <
models>
        <
sales>
            <
rewrite>
                <
order_pdf_shipment>
                    
Symmetrics_Sales_Model_Order_Pdf_Shipment
                
</order_pdf_shipment>
            </
rewrite>
        </
sales>
    </
models>
</
config>

app/code/local/Symmetrics/Sales/Model/Order/Pdf/Shipment.php

<?php

class Symmetrics_Sales_Model_Order_Pdf_Shipment extends Mage_Sales_Model_Order_Pdf_Shipment
{
    
public function __construct ()
    
{
        
echo 'Hallo World!' ;
    
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
John
Sr. Member
 
Avatar
Total Posts:  129
Joined:  2007-12-20
Sheffield, United Kingdom
 

This got me for ages here is how I solved it as I describe below.  But before that can I suggest that you change your line

<order_pdf_shipment>
                    
Symmetrics_Sales_Model_Order_Pdf_Shipment
                
</order_pdf_shipment>

to

<order_pdf_shipment>Symmetrics_Sales_Model_Order_Pdf_Shipment</order_pdf_shipment>

Now I changed the following to reflect the override of all the appropriate files

<global>
     <
models>
        <
sales>
            <
rewrite>
                <
order_pdf_abstract>CC_Sales_Model_Order_Pdf_Abstract</order_pdf_abstract>   
                <
order_pdf_shipment>CC_Sales_Model_Order_Pdf_Shipment</order_pdf_shipment
                <
order_pdf_invoice>CC_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice
                <
order_pdf_creditmemo>CC_Sales_Model_Order_Pdf_Creditmemo</order_pdf_creditmemo>
                   <
order_pdf_items_creditmemo_default>CC_Sales_Model_Order_Pdf_items_Creditmemo_Default</order_pdf_items_creditmemo_default>
                   <
order_pdf_items_invoice_default>CC_Sales_Model_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default>
                   <
order_pdf_items_shipment_default>CC_Sales_Model_Order_Pdf_Items_Shipment_Default</order_pdf_items_shipment_default>
                   <
order_pdf_items_abstract>CC_Sales_Model_Order_Pdf_Items_Abstract</order_pdf_items_abstract
                </
rewrite>
            </
sales>
         </
models>
    </global>
</
config>

Noting that the shipping must point to the override abstract if required.  For example :

class CC_Sales_Model_Order_Pdf_Shipment extends CC_Sales_Model_Order_Pdf_Abstract

Regards
John

 
Magento Community Magento Community
Magento Community
Magento Community
 
symmetrics_bl
Member
 
Avatar
Total Posts:  58
Joined:  2008-01-07
Hannover
 

@John

thanks for your help!

the problem were somewhere else… the module was not been <b>loaded</b>. the reason:

...
        <
Symmetrics_Sales>
            <
active>
                
true
            
</active>
            <
codePool>
                
local
            
</codePool>
        </
Symmetrics_Sales>
...

of course this has the be:

...
        <
Symmetrics_Sales>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Symmetrics_Sales>
...
 
Magento Community Magento Community
Magento Community
Magento Community
 
John
Sr. Member
 
Avatar
Total Posts:  129
Joined:  2007-12-20
Sheffield, United Kingdom
 

This is the same with all the config files.  **Sp ace s are ba d**

Glad that you solved the problem
John

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

Do your changes in Abstract.php take effect?

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