4

I want to overwrite Mage_Paypal_Model_Api_Nvp in my custom_module. For this, I have follow following steps but after that also core file is calling.

config.xml

 <models>
     <paypal>
       <rewrite>
          <api_nvp>Mycompany_Modulename_Model_Api_Nvp</api_nvp>
      </rewrite>
    </paypal>
</models>

Nvp.php

class Mycompany_Modulename_Model_Api_Nvp extends Mage_Paypal_Model_Api_Nvp
{
    <!-- Code -->
}

I have cleared cache, session, logs. But after that also my file is not called.

6
  • please check complier]
    – Amit Bera
    Jun 3, 2015 at 17:53
  • compiler is not enabled.
    – Krupali
    Jun 3, 2015 at 17:54
  • check class name by echo get_class(Mage::getModel('paypal/api_nvp')) is Mycompany_Modulename_Model_Api_Nvp. If it will given value Mycompany_Modulename_Model_Api_Nvp then the rewrite is proper
    – Amit Bera
    Jun 3, 2015 at 17:56
  • core file is called :(
    – Krupali
    Jun 3, 2015 at 18:01
  • Could you post the full config.xml fragment? The <models/> node should be inside <config><global>...
    – 7ochem
    Jun 3, 2015 at 19:15

1 Answer 1

1

Your code definitely looks ok.

As the full config.xml file is missing here is what it should look like to ensure your rewrite works:

app/code/local/Mycompany/Modulename/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Mycompany_Modulename>
      <version>0.0.1</version>
    </Mycompany_Modulename>
  </modules>
  <global>
        <models>  
            <paypal>
                <rewrite>
                    <api_nvp>Mycompany_Modulename_Model_Api_Nvp</api_nvp>
                </rewrite>
            </paypal>
        </models>
    </global> 
</config> 

Then you need to you ensure the path to your custom model is right, it should be app/code/local/Mycompany/Modulename/Model/Api/Nvp.php

Once you're done with that don't forget to:

  • recompile
  • flush the cache

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.