Good morning everybody!
I have a problem trying to override the model app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php
with app/code/local/Mycompany/Sales/Model/Order/Pdf/Total/Default.php
.
The thing is that when I rewrite the module but Magento is using the old module without override.
Here I upload the relevant codes:
etc/modules/Mycompany_Sales.xml
<?xml version="1.0"?> <config> <modules> <Mycompany_Sales> <active>true</active> <codePool>local</codePool> <depends> <Mage_Sales /> </depends> </Mycompany_Sales> </modules> </config>
app/code/local/Mycompany/Sales/etc/config.xml
<?xml version="1.0"?> <config> <modules> <Mycompany_Sales> <version>0.1.0</version> </Mycompany_Sales> </modules> <global> <models> <sales> <rewrite> <order_pdf_total_default>Mycompany_Sales_Model_Order_Pdf_Total_Default</order_pdf_total_default> </rewrite> </sales> </models> </global> </config>
code/local/Mycompany/Sales/Model/Order/Pdf/Total/Default.php
<?php class Mycompany_Sales_Model_Order_Pdf_Total_Default extends Mage_Sales_Model_Order_Pdf_Total_Default { public function getFullTaxInfo() { ... } }
I have compared it with some internet examples of models overriding and everything seems to be alright.
Anyone knows what can be the problem?
Thank you very much!!
[EDIT]
Finally I have solved the problem.
The thing is that there is a core file app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php
that overrides app/code/core/Mage/Sales/Order/Pdf/Total/Default.php
so my extended class was in conflict with the tax class.
For solving it I rewrite my extension in order to extends app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php
.
The result is:
- etc/modules/Mycompany_Sales.xml
<?xml version="1.0"?> <config> <modules> <Mycompany_Sales> <active>true</active> <codePool>local</codePool> <depends> <Mage_Sales /> <Mage_Tax /> </depends> </Mycompany_Sales> </modules> </config>
app/code/local/Mycompany/Sales/etc/config.xml
<?xml version="1.0"?> <config> <modules> <Mycompany_Sales> <version>0.1.0</version> </Mycompany_Sales> </modules> <global> <models> <tax> <rewrite> <sales_pdf_grandtotal>Mycompany_Sales_Model_Order_Pdf_Total_Default</sales_pdf_grandtotal> </rewrite> </tax> </models> </global> </config>
code/local/Mycompany/Sales/Model/Order/Pdf/Total/Default.php
<?php class Mycompany_Sales_Model_Order_Pdf_Total_Default extends Mage_Tax_Model_Sales_Pdf_Grandtotal { public function getFullTaxInfo() { ... } }
get_class(Mage::getModel('sales/order_pdf_total_default'));
?get_class(Mage::getModel('sales/order_pdf_total_default'));
a weird thing happens, it shows my classMycompany_Sales_Model_Order_Pdf_Total_Default
instead the old one.