Rewrite core model

example: we will rewrite Mage_Newsletter_Model_Subscriber in order to disable send success subscriber and send unsubscription mail function :

in config.xml:

   <global>
         <models>
         	<mynewsletter>
				<class>Bysoft_Mynewsletter_Model</class>
				<resourceModel>mynewsletter_mysql4</resourceModel>
	  		</mynewsletter>
            <newsletter>
                <rewrite>
                    <subscriber>Bysoft_Mynewsletter_Model_Subscriber</subscriber>
                </rewrite>
            </newsletter>
        </models>
    </global>

 create custom model class to rewrite core model class:

<?php
class Bysoft_Mynewsletter_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
{
	/**
	 * Sends out confirmation success email
	 *
	 * @return Mage_Newsletter_Model_Subscriber
	 */
	public function sendConfirmationSuccessEmail()
	{
		return $this;
	}
	/**
	 * Sends out unsubsciption email
	 *
	 * @return Mage_Newsletter_Model_Subscriber
	 */
	public function sendUnsubscriptionEmail()
	{
		return $this;
	}
}

 

你可能感兴趣的:(rewrite)