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:

app/code/local/Path/To/File/To/Override.php

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

<config>
....
<global>
<models>
<catalog>
<rewrite> <product>MyModule_Model_Product</product>
</rewrite>
</catalog>
</models>
</global>
..... </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 (http://www.neotheme.com.au/magento/n-restrict.html):

<config>
.....
<frontend>
    <events>
        <catalog_product_is_salable_after>
            <observers>
                <neotheme_restrictproductcheckout>
                    <type>model</type>
                    <class>neotheme_restrictproductcheckout/catalog_product_observer</class>
                    <method>onCatalogAfterIsSalable</method>
                </neotheme_restrictproductcheckout>
            </observers>
       </catalog_product_is_salable_after>
    </events>
</frontend>
.....
</config>

Then inside the Observer class:

class NeoWare_RestrictProductCheckout_Model_Catalog_Product_Observer
extends Mage_Core_Model_Abstract
{
    function onCatalogAfterIsSalable(Varien_Event_Observer $observer){
         $observer->getProduct()->setChangeSomeData(true);
   }
}

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