我想覆盖一个抽象的magento类。即Mage_Customer_Model_Address_Abstract。我的意图是摆脱电话号码验证。
我尝试复制 app/code/ core / Mage /Customer/Model/Address/Abstract.php
至
app/code/ local /Telephone/Customer/Model/Address/ Abstract.php
试图用新代码覆盖函数 validate()。
public function validate()
    {
        $errors = array();
        $this->implodeStreetAddress();
        if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the first name.');
        }
        if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the last name.');
        }
        if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the street.');
        }
        if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the city.');
        }
       /* if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the phone number.');
        } */
        $_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
        if (!in_array($this->getCountryId(), $_havingOptionalZip)
            && !Zend_Validate::is($this->getPostcode(), 'NotEmpty')
        ) {
            $errors[] = Mage::helper('customer')->__('Please enter the zip/postal code.');
        }
        if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
            $errors[] = Mage::helper('customer')->__('Please enter the country.');
        }
        if ($this->getCountryModel()->getRegionCollection()->getSize()
               && !Zend_Validate::is($this->getRegionId(), 'NotEmpty')
               && Mage::helper('directory')->isRegionRequired($this->getCountryId())
        ) {
            $errors[] = Mage::helper('customer')->__('Please enter the state/province.');
        }
        if (empty($errors) || $this->getShouldIgnoreValidation()) {
            return true;
        }
        return $errors;
    }
但是,我不能让它工作!
我能做到的唯一方法是将文件完全复制到本地文件夹。IE
app/code/ core/Mage/ Customer/Model/Address/ Abstract.php
至
app/code/ local/Mage/ Customer/Model/Address/ Abstract.php
我在 app/code/local/Customer/etc/ 中的 config.xml 是..
<?xml version="1.0"?>
<config>
    <modules>
        <Telephone_Customer>
            <version>0.0.1</version>
        </Telephone_Customer>
    </modules>
    <global>
    <models>
    <telephone_customer>
        <class>Telephone_Customer_Model</class>
    </telephone_customer>
    <customer>
        <rewrite>
            <customer>Telephone_Customer_Model_Customer</customer>
        </rewrite>
    <customer>
    </models>
    </global>   
</config>
但是这里不允许这样做,因为这不是正确的做法。
我们可以像在其他地方所做的那样覆盖这个抽象类吗?
请帮忙。