Skip to content

Instantly share code, notes, and snippets.

@svenvarkel
Created September 14, 2013 05:26
Show Gist options
  • Save svenvarkel/6559042 to your computer and use it in GitHub Desktop.
Save svenvarkel/6559042 to your computer and use it in GitHub Desktop.
trait My_Custom_Trait_Extension_A_Model_Product
trait My_Custom_Trait_Extension_A_Model_Product{
/**
* This method loads the original, rewritten class of
* Extension_A_Model_Product. Mind the shorthand - you need
* to load correct original class.
* $this becomes later part of My_Custom_Model_Product context
*/
protected function getInstance()
{
if ( is_null($this->_instance) )
{
$this->_instance = Mage::getModel('extensiona/product')->load($this->getId());
}
return $this->_instance;
}
/**
* Add "implementation" of base class method
* doSomethingImportant here.
*/
public function doSomethingImportant(){
return $this->getInstance()->doSomethingImportant();
}
public function transformProductDescription(){
return $this->getInstance()->transformProductDescription();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment