Search code examples
phpmagentomodeloverriding

Magento override core model


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() . "|!\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);
        }
    }
}

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!


Solution

  • Use this

    <codePool>local</codePool>