Php Magento覆盖核心模型
我知道这已经被问了好几次了,但我已经看完了答案,仍然不明白为什么我不能覆盖Magento中的核心模型: 我试图覆盖Eav/Attribute/Data/Text.php,但它拒绝使用我版本的Php Magento覆盖核心模型,php,magento,model,overriding,core,Php,Magento,Model,Overriding,Core,我知道这已经被问了好几次了,但我已经看完了答案,仍然不明白为什么我不能覆盖Magento中的核心模型: 我试图覆盖Eav/Attribute/Data/Text.php,但它拒绝使用我版本的validateValue()函数 这是我的模型类/app/code/local/Hailstorm/Eav/model/Attribute/Data/Text.php class Hailstorm_Eav_Model_Attribute_Data_Text extends Mage_Eav_Model_A
validateValue()
函数
这是我的模型类/app/code/local/Hailstorm/Eav/model/Attribute/Data/Text.php
class Hailstorm_Eav_Model_Attribute_Data_Text extends Mage_Eav_Model_Attribute_Data_Text {
public function validateValue($value) {
$attribute = $this->getAttribute();
echo "My validator for |" . $attribute->getAttributeCode() . "|!\n";
if ($attribute->getAttributeCode() == 'postcode') {
$countryId = $this->getExtractedData('country_id');
$optionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
if (!in_array($countryId, $optionalZip)) {
return parent::validateValue($value);
}
return true;
}
else {
return parent::validateValue($value);
}
}
}
这是我的config.xml/app/code/local/Hailstorm/Eav/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<hailstorm_eav>
<version>0.1.0</version>
</hailstorm_eav>
</modules>
<global>
<models>
<eav>
<rewrite>
<attribute_data_text>Hailstorm_Eav_Model_Attribute_Data_Text</attribute_data_text>
</rewrite>
</eav>
</models>
<hailstorm_eav>
<class>Hailstorm_Eav_Model</class>
</hailstorm_eav>
</global>
</config>
0.1.0
冰雹天气模式属性数据文本
雹暴Eav模式
这是我的模块xml文件
/app/etc/modules/Hailstorm_Eav.xml
<?xml version="1.0"?>
<config>
<modules>
<hailstorm_eav>
<active>true</active>
<codepool>local</codepool>
</hailstorm_eav>
</modules>
</config>
真的
地方的
我已经阅读了这里的教程和其他类似问题的答案,但我看不出我做错了什么
感谢您的帮助使用此
<codePool>local</codePool>
本地
config.xml和Hailstorm\u Eav.xml的类声明中存在问题
在冰雹_Eav.xml中
hailstorm\u eav
tohailstorm\u eav
和config.xml中的
<hailstorm_eav>
<version>0.1.0</version>
</hailstorm_eav>
0.1.0
应该是
<Hailstorm_Eav>
<version>0.1.0</version>
</Hailstorm_Eav>
0.1.0
正如Vishal Sharma所说的代码池语法