First of all, I apologize for asking another question about redirecting the magento core, but I followed about 10 tutorials and read almost all of the similar questions posted here without success.
I need to redefine a bunch of basic models and classes. The code works because I already changed the kernel (on the test magento site) and it worked fine. But from time to time, a magento update is available, and if we apply the updates, all my changes will be lost. Therefore, I have to redefine the base code. I want to make my own module for entering all the necessary code, because I only need to redefine 1 or 2 functions in each class, the rest should work as Magento expected.
My first attempt was to override the Mage_Sales_Model_Order_Pdf_Invoice class. Ok, so I made my module. File structure:
Applications / code / local / [names] /Sales/etc/config.xml
Application / code / local / [names] /Sales/Helper/Data.php (This class does nothing, it's just an empty class. I did this because I read somewhere that Magento sometimes does not recognize a module, if there is no Helper class)
Application / code / local / [names] /Sales/Model/Order/Pdf/Invoice.php
<strong> application / etc / modules / [names] _Sales.xml
The [namespace] _Sales.xml file is as follows:
<?xml version="1.0"?> <config> <modules> <[namespace]_Sales> <active>true</active> <codePool>local</codePool> </[namespace]_Sales> </modules> </config>
The config.xml file is as follows:
< ?xml version="1.0"?> <config> <modules> <[namespace]_Sales> <version>0.1.0</version> </[namespace]_Sales> </modules> <global> <helpers> <sales> <class>[namespace]_Sales_Helper</class> </sales> </helpers> <models> <sales> <rewrite> <order_pdf_invoice>[namespace]_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice> </rewrite> </sales> </models> </global> </config>
And the Invoice.php file looks like this:
<?php include_once Mage::getBaseDir('lib')."/myclass.php"; include_once Mage::getBaseDir('lib')."/another_library.php"; class [namespace]_Sales_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice { public function getPdf($invoices = array()) {
I wanted to test this first before moving on and overriding all the other controllers and models that I need to change.
The problem is that she is still using the original model.
I think the module code and paths are correct because magento finds my own model. I checked by going into the backend and looked at System-> configuration-> advanced
I completely cleared the cache so it wasnโt.
I used get_class to determine which model returns to the controller: get_class (Mage :: getModel ('sales / order_pdf_invoice')) . This returns Mage_Sales_Model_Order_Pdf_Invoice
I do not know where I made a mistake, but I'm sure I did one: (