3
votes

I need to rewrite a magento core model. In that core model class i just need to change a one line in a one function.

My problem is when im rewriting this core model should i have to copy other (unchanged) method also in my new model class. or should i only redefine the method that need to modify.

Thanks.

1

1 Answers

4
votes

Extend your class off the class you want to rewrite and just define the method you need to modify in there, all other methods can be excluded as a call to any of these other methods will just run off the original parent class as long as the scope isn't private.

Best practice where possible is to run the original parent method from your new method (using parent::yourMethodName($args)) and just modify data either sent to, or returned from the parent method, this keeps things a bit more upgrade friendly. Failing that just copy and alter the original parent method in your new class.