1

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 ?

7
  • Can you add config.xml from OtherCompany` module?
    – sv3n
    Jul 31, 2018 at 12:42
  • what do you mean ? Jul 31, 2018 at 15:06
  • Can you add config.xml from the module that you want to rewrite?
    – sv3n
    Jul 31, 2018 at 22:24
  • @OrazioD'Arrigo did u see my answer ?
    – sami23
    Aug 3, 2018 at 15:08
  • yes, I delayed answering, sorry. then it worked, but between one problem and another, only today I managed to get back on the forum Aug 3, 2018 at 15:19

2 Answers 2

1

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>

0

I think your issue is the config.xml that you've written. You generally would define your own model namespace "mymodule", then another node for the namespace you're rewriting ("api"), and put your rewrite in there. See below:

...
<models>
    <mymodule>
        <class>MyCompany_MyModule_Model</class>
    </mymodule>
    <api>
        <rewrite>
            <rest>MyCompany_MyModule_Model_Api_Rest_Client</rest>
        </rewrite>
    </api>
</models>
...
3
  • 1
    Your own model declaration is wrong.
    – sv3n
    Jul 31, 2018 at 12:12
  • 1
    Hi @sv3n, thanks for pointing that out! Stupid mistake when copying it out on my part... I've edited and should have corrected this now. Hope it works! Jul 31, 2018 at 12:38
  • thanks for the tip but it does not work Jul 31, 2018 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.