Warning: Redis::connect(): connect() failed: Connection refused in /var/www/admclub.com/wp-content/object-cache.php on line 418
扩展Magento核心静态类的方法(3) | _站长俱乐部站长俱乐部

扩展Magento核心静态类的方法(3)

Hi everyone. I don’t know if its because of my Magento version on what, but I couldn’t make Paul’s solution work.

The problem is that apparently when I make static function calls to my specialized class, this one is rewriten in my config file so I can’t access that class no more.

What I ended up doing, and appears to work quite well is to extend the Mage_Sales_Model_Order_Pdf_Invoice class with my own abstract class which of course extends the Mage_Sales_Model_Order_Pdf_Abstract so I can access all of its methods and rewrite it from there.

Then I created my own Invoice class (Pwc_Sales_Model_Order_Pdf_Invoice) to extend my new abstract class. This gives me a way to overwrite all the necessary methods without having to call the static methods.

At the end what you should get is something like this:

abstract Class Mage_Sales_Model_Order_Pdf_Abstract extends Mage_Sales_Model_Order_Pdf_Invoice {
/*
Rewrite necessary methods from Mage_Sales_Model_Order_Pdf_Abstract Class here
*/
}
Class Pwc_Sales_Model_Order_Pdf_Invoice extends Pwc_Sales_Model_Order_Pdf_Abstract {
/*
Rewrite methods from Mage_Sales_Model_Order_Pdf_Invoice if necessary
*/
}

Then don’t forget to rewrite the class Mage_Sales_Model_Order_Pdf_Invoice with your own Pwc_Sales_Model_Order_Pdf_Invoice in your config.xml file.

Hope this helps someone.

by felo

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>