Magento cannot override Mage_Payment_Model_Method_Cc.php file

Explanation is easy here.

There is a class Mage_Payment_Model_Method_Cc which has a lot of methods. The other class Mage_Payment_Model_Method_Ccsave is extended from it. It has few protected properties. All methods it takes from it's parent.

When magento is looking for some method from Mage_Payment_Model_Method_Ccsave and didn't find it there - it goes to it's parent method.

As result you see in xdebug that you are referring to Mage_Payment_Model_Method_Cc. But if you look which class is inside $this - you will see Mage_Payment_Model_Method_Ccsave.


I tried lot of ways finally i got the solution.

config.xml

<?xml version="1.0"?>
<config>
   <modules>
      <Naveed_Abbas>
          <version>0.1.0</version>
      </Naveed_Abbas>
   </modules>
   <global>
     <models>
        <payment>
          <rewrite>
            <method_ccsave>Naveed_Abbas_Model_Payment_Method_Cc</method_ccsave>
           </rewrite>
        </payment>
     </models>
   </global>
 </config>

Naveed/Abbas/Model/Payment/Method/Cc.php :

<?php

   class Naveed_Abbas_Model_Payment_Method_Cc extends Mage_Payment_Model_Method_Ccsave{

      public function isAvailable($quote = null) {
         echo "Test"; //sssssssexit;
         Mage::log("Canel Order",null,'isAvailable-test-1.log'); exit;
         return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
        && parent::isAvailable($quote);
     }    
  }