Created
September 14, 2013 05:35
-
-
Save svenvarkel/6559077 to your computer and use it in GitHub Desktop.
My_Custom_Trait_Extension_B_Model_Product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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