Skip to content

Instantly share code, notes, and snippets.

@svenvarkel
Created September 14, 2013 05:35
Show Gist options
  • Save svenvarkel/6559077 to your computer and use it in GitHub Desktop.
Save svenvarkel/6559077 to your computer and use it in GitHub Desktop.
My_Custom_Trait_Extension_B_Model_Product
trait My_Custom_Trait_Extension_A_Model_Product{
/**
* This method loads the original, rewritten class of
* Extension_B_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('extensionb/product')->load($this->getId());
}
return $this->_instance;
}
/**
* Implement original class' isAvailable
*/
public function isAvailable(){
return $this->getInstance()->isAvailable();
}
/**
* Implement original class' fixSomethingByProduct
*/
public function fixSomethingByProduct(){
return $this->getInstance()->fixSomethingByProduct();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment