I want to Override an abstract class of magento. ie Mage_Customer_Model_Address_Abstract
. My intention is to get rid of Telephone number validation.
I tried copying app/code/core/Mage/Customer/Model/Address/Abstract.php
To
app/code/local/Telephone/Customer/Model/Address/Abstract.php
Tried to Override the function validate() with new code.
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;
}
But, I cant make it work!
Only way i can do it is by exactly copying the file to local folder. ie
app/code/core/Mage/Customer/Model/Address/Abstract.php
To
app/code/local/Mage/Customer/Model/Address/Abstract.php
and my config.xml in app/code/local/Customer/etc/ is..
<?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>
But it is not allowed here bcz its not the right way to do it.
Can we override this abstract class like what we do in elsewhere..?
Please help.