2
votes

The class I want to override is in app\code\community\Dhl\Intraship\Model\Gateway.php. So I placed that class in my local module in app\code\local\MyCompany\Intraship\Model\Gateway.php and changed the class name accordingly.

Now what do I have to add to my config.xml file in order to make that work?

Thanks!

1

1 Answers

6
votes

The node under models should match the same one in app\code\community\Dhl\Intraship\etc\config.xml :

<?xml version="1.0"?>
<config>
    <modules>
        <Dhl_Intraship>
            <version>13.07.04</version>
        </Dhl_Intraship>
    </modules>
    <!-- some more code here -->
    <global>
        <models>
            <intraship> <!-- this is the node you have to look at -->
                <class>Dhl_Intraship_Model</class>
                <resourceModel>intraship_mysql4</resourceModel>
            </intraship>
            <!-- some more code here -->
        </models>
    <!-- some more code here -->
    <global>
</config>

And the node under rewrite have to match the path of the file you want to rewrite under the folder Model : so in you case it is just gateway. But if you were to rewrite app\code\community\Dhl\Intraship\Model\Path\To\Some\Model.php the node would have been path_to_some_model

So it should looks like that :

<?xml version="1.0"?>
<config>
    <modules>
        <mycompany_intraship>
            <version>0.1.0</version>
        </mycompany_intraship >
    </modules>
    <global>
       <models>
          <intraship>
              <rewrite>
                  <gateway>MyCompany_Intraship_Model_Gateway</gateway>
              </rewrite>
          </intraship>
       </models>
    </global>
</config>