It's easy to get tripped up and mystified by Magento's class rewrites, because they seem like voodoo at first. However, outside of the "instantiate this class instead of this other class" functionality, class rewrites are just standard PHP OOP, and all standard PHP OOP rules apply.
Specifically, if your class extends another class, it will not have access to private properties of the base class/object.
private $_customerEmailExistsMessage = '';
You will have access to protected and public properties and methods. You could redefine the __constructor
method if you wanted
public function __construct()
{
//do the stuff in the parent consturctor
parent::__construct();
//do my new stuff
}
You don't need to call parent::__construct()
, but it's always a good idea to do this unless you have a reason not to. The parent::methodName()
syntax will work with other methods as well
public function getCheckout()
{
$parent_results = parent::getCheckout();
//do my stuff
return $parent_results;
}
Constants are a bit trickier. While constants don't have access rules like member functions and variables, depending on your version of PHP (5.2 vs. 5.3 and greater), PHP's "Late Static Bindings" behavior will change how its special 'self', 'parent', and 'static' keywords interact with constants. Generally speaking, the Magento codebase uses the full class name when referencing constants
echo Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
I've tended to, and recommend you, do the same.