나는 자홍색 추상 클래스를 오버라이드하고 싶습니다. 즉 Mage_Customer_Model_Address_Abstract
입니다. 제 의도는 전화 번호 확인을 없애는 것입니다.Magento에서 추상 클래스를 어떻게 재정의 할 수 있습니까?
I 앱/코드/코어를 복사 시도 /Mage/Customer/Model/Address/Abstract.php
으로응용 프로그램/코드/지역/전화/고객/모델/주소 /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;
}
하지만 제대로 작동하지 않습니다.
내가 할 수있는 유일한 방법은 파일을 로컬 폴더에 정확하게 복사하는 것입니다. 즉
응용 프로그램/코드/코어/마법사 /Customer/Model/Address/Abstract.php
하려면 응용 프로그램/코드/ 지역/마법사/고객/모델/주소/추상 .PHP 및 응용 프로그램/코드/지역/고객/기타 /입니다 내 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>
B 유엔 여기에 그것이 올바른 방법이 아니라는 bcz 허용되지 않습니다.
다른 곳에서하는 것처럼이 추상 클래스를 재정의 할 수 있습니까?
도와주세요.
class SomeClass extends Abstract {...? – vodich
나는 이미 그것을 시도했다. 클래스는 Telephone_Customer_Model_Address_Abstract는 Mage_Customer_Model_Address_Abstract { } 를 확장하지만 ... :( –