3
votes

I am trying to rewrite Magento Address Model but I'm going crazy with this. My config.xml rewrite section looks like this

<models>
    <customer>
         <rewrite>
             <customer>MyNam_MyMod_Model_Customer</customer>
             <address>MyNam_MyMod_Customer_Model_Address</address>
         </rewrite>
    </customer>
</models>

and my class looks like:

require_once 'Mage/Customer/Model/Address.php';
class MyNam_MyMod_Customer_Model_Address extends Mage_Customer_Model_Address
{


public function validate() {
    parent::validate();
}
}

When I load address form I get the following error: Call to a member function getId() on a non-object in /var/www/magento/app/code/core/Mage/Customer/Block/Address/Edit.php on line 53

I noticed that edit block is unable to load customer/address model

Can anyone help me?

2

2 Answers

0
votes

i hope in class address MyNam_MyMod_Customer_Model_Address ,i should be MyNam_MyMod_Model_Address

<models>
    <customer>
         <rewrite>
             <customer>MyNam_MyMod_Model_Customer</customer>
             <address>MyNam_MyMod_Model_Address</address>
         </rewrite>
    </customer>
</models> 

let me know, if you have any issue...

0
votes

First of all remove the line require_once 'Mage/Customer/Model/Address.php'; You don't need this because classes are loaded automatically. The rest of your code looks correct. Did you clear your var/cache folder?