Magento 1.9 – How to Override Model

magento-1.9modeloverrides

Path File i want Override
app\code\community\OtherCompany\core\Model\Api\Rest\Client.php

Path my file override
app\code\local\MyCompany\MyModule\Model\Api\Rest\Client.php

app\etc\modules\MyCompany_MyModule.xml After change

<config>
    <modules>
        <MyCompany_MyModule>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <OtherCompany_Payments/>
                <OtherCompany_Core/>
            </depends>
        </MyCompany_MyModule>
    </modules>
</config>

config.xml

<config>
    <global>
        <models>
            <mymodule>
                <class>MyCompany_MyModule_Model</class>
            </mymodule>
            <rewrite>
               <api>
                  <rest>MyCompany_MyModule_Model_Api_Rest_Client</rest>
               </api>
            </rewrite>
        </models>
    </global>
</config>

My File path:
app\code\local\MyCompany\MyModule\Model\Api\Rest\Client.php

class MyCompany_MyModule_Model_Api_Rest_Client extends OtherCompany_Core_Model_Api_Rest_Client  {

protected function _construct() 
{
    highlight_string(print_r('_construct',true));
    exit();
} }

are the declared routes correct?
or it may depend on the etc \ module file

where is specified
I should write
or

and in case the code depends on
is compromised if I write only ?

Best Answer

Can you try this and let me know if works

<config>
<global>
    <models>
        <mymodule>
            <class>MyCompany_MyModule_Model</class>
        </mymodule>
        <mymodule_api_rest>
          <rewrite>      
             <client>MyCompany_MyModule_Model_Api_Rest_Client</client>
          </rewrite>
        </mymodule_api_rest>
    </models>
</global>