There are several ways to override any particluar class in Magento.

The first (and probably the most "brute force") way is to put it in the local codepool:


Magento's autoloader loads the codepools (located at app/code) in the following order

  1. local
  2. community
  3. core

So any files with the same path in the local code pool will be loaded before the files in the core. When Magento is upgraded, you'll need to make your changes to your local override if the core file is updated.

The Second way is to write a re-writing module (in the config.xml):

Then inside

<rewrite> <product>MyModule_Model_Product</product>
..... </config>
MyModule_Model_Product extends Mage_Model_Product
	public function toOverride(){
		//Stuff the parent way, mines better!
		return “myresult”;

The Third way is to tap into a dispatched event (if it exists) Taken from our restricting checkout module (


Then inside the Observer class:

class NeoWare_RestrictProductCheckout_Model_Catalog_Product_Observer
extends Mage_Core_Model_Abstract
    function onCatalogAfterIsSalable(Varien_Event_Observer $observer){

Ideally you’d always use events, so you’d never break functionality. But each overriding system has it’s place.