dopcpc9207 2014-08-11 14:56
浏览 33
已采纳

Magento覆盖核心模型

I know this has been asked a few times on here, but I've been through the answers and still can't figure out why I can't override a core model in Magento:

I am trying to override the Eav/Attribute/Data/Text.php but it refuses to use my version of the validateValue() function.

Here is my model class /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() . "|!
";

        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);
        }
    }
}

Here is my 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>

And here is my module xml file

/app/etc/modules/Hailstorm_Eav.xml

<?xml version="1.0"?>
<config>
    <modules>
        <hailstorm_eav>
            <active>true</active>
            <codepool>local</codepool>
        </hailstorm_eav>
    </modules>
</config>

I've been through the tutorials and the answers to other questions like this on here, but I can't see what I'm doing wrong!

Thanks for any help

  • 写回答

2条回答 默认 最新

  • dousi0144 2014-08-11 15:05
    关注

    Use this

    <codePool>local</codePool>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?