0

It is required to overwrite customer_resource class. I added required config.xml options for resource rewriting, but when overwritten class method calls parent class method from itself, it actually called the parent method from which I extend to, nor the parent of Mage_Customer_Model_Resource_Customer:

  class My_Plugin_Model_Resource_Customer extends Mage_Customer_Model_Resource_Customer 
    {

    protected function _beforeSave(Varien_Object $customer){
        parent::_beforeSave($customer);
    ...
        }
    }

So, how to call parent method correctly in this case ? some kind of double downcasting is possible in PHP?

Update:

if found some solution, but not sure if it worked for me, cause via the customer_entity table it still not saves customer correctly:

        call_user_func(array(get_parent_class(get_parent_class($this)), 
                       '_beforeSave', $customer));
0

The easiest solution, in particular this case, was to call:

Mage_Eav_Model_Entity_Abstract::_beforeSave($customer);

as the required parent of Mage_Customer_Model_Resource_Customer is Mage_Eav_Model_Entity_Abstract it will call the grandparent.

also, there is method with ReflectionMethod->invoke()

more info here: https://stackoverflow.com/questions/12850802/how-to-call-grandparent-method-without-getting-e-strict-error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.