Magento 1.7覆盖Pdf类 [英] Magento 1.7 Override Pdf Classes
问题描述
我试图覆盖Pdf类以更改Invoice/Shipment/Creditmemo pdf,但它似乎没有体现.
I tried to override Pdf classes for making changes toInvoice/Shipment/Creditmemo pdf but it doesnt seem to reflect.
我在Mymodule/etc/config.xml中使用以下命令创建了一个模块
I created a module with following in the Mymodule/etc/config.xml
<config>
<modules>
<Mymodule_Printtemplates>
<version>0.1.0</version>
</Mymodule_Printtemplates>
</modules>
<global>
<models>
<sales>
<rewrite>
<order_pdf_abstract>Mymodule_Printtemplates_Model_Order_Pdf_Abstract</order_pdf_abstract>
<order_pdf_invoice>Mymodule_Printtemplates_Model_Order_Pdf_Invoice</order_pdf_invoice>
<order_pdf_creditmemo>Mymodule_Printtemplates_Model_Order_Pdf_Creditmemo</order_pdf_Creditmemo>
<order_pdf_shipment>Mymodule_Printtemplates_Model_Order_Pdf_Shipment</order_pdf_shipment>
</rewrite>
</sales>
</models>
</global>
然后我在Mymodule/models/中创建了以下Model类 作为Abstract.php,Invoice.php,Shipment.php,Creditmemo.php
Then I created following Model classes in Mymodule/models/ as Abstract.php, Invoice.php, Shipment.php, Creditmemo.php
abstract class Mymodule_Printtemplates_Model_Order_Pdf_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
class Mymodule_Printtemplates_Model_Order_Pdf_Invoice extends Mymodule__Printtemplates_Model_Order_Pdf_Abstract { ... functions here ...}
class Mymodule_Printtemplates_Model_Order_Pdf_Shipment extends Mymodule__Printtemplates_Model_Order_Pdf_Abstract{ ... functions here ...}
class Mymodule_Printtemplates_Model_Order_Pdf_Creditmemo extends Mymodule__Printtemplates_Model_Order_Pdf_Abstract{ ... functions here ...}
该模块已启用-我已经通过系统">配置">管理">高级"对其进行了检查,但它似乎没有反映出更改
The module is enabled - I have checked it through System>Configuration>Admin>Advanced but it doesn't seem to reflect the changes
另一方面,如果我将Mage/Sales/Model/Order/Pdf/*.php复制粘贴到本地并进行更改,则会反映出更改.我知道这不是推荐的方法,但是通过重写类的方法似乎不起作用.
On the other-hand, if I copy paste Mage/Sales/Model/Order/Pdf/*.php into local and change, changes are reflected. I know this is not a recommended method but the method via rewriting classes doesnt seem to work.
通过类重写为第一种方法提供的任何帮助将不胜感激.
Any help for the first method via class rewrite would be appreciated.
谢谢, 洛夫琳
真正的问题是etc/config.xml中的语法错误[请参见大写C结束标记]
The real problem was a Syntax in error in etc/config.xml [see Capital C in ending tag]
Mymodule_Printtemplates_Model_Order_Pdf_Creditmemo
Mymodule_Printtemplates_Model_Order_Pdf_Creditmemo
我使用以下步骤调试了该问题:将其放在index.php的底部,类似于Alans Module List,但是使用了快速的代码复制/粘贴方法.请记住,Magento的所有XML都合并到一个XML树中.
I used the following to debug the issue: Drop this in the bottom of your index.php, similar to Alans Module List but a quick code copy/paste approach. Remember all of Magento's XML's get combined into one XML tree.
header("Content-Type:text/xml"); die(Mage :: app()-> getConfig()-> getNode()-> asXML());
header("Content-Type: text/xml"); die(Mage::app()->getConfig()->getNode()->asXML());