Yes, it is possible, and you are doing it almost right.
Since your class depends on another module, you must mention this in the class declaration as follows:
PHP Code:
namespace XLite\Module\Grempels\Restfully\Model; /** * @Decorator\Depend("XC\ProductVariants")*/class ProductVariant extends \XLite\Module\XC\ProductVariants\Model\ProductVariant implements \XLite\Base\IDecorator{ public function getProductId() { return $this->getProduct()->getProductId(); }}
Quote:
And why ProductVariantAbstract ? I extend ProductVariant.
|
When re-deploying the site X-Cart finds all classes that "decorate" (the "implements \XLite\Base\IDecorator" thing) core classes or other modules and then rewrite the source code to make them extend each other in the correct order.
The resulting code ends up in the var/run/classes/ directory, and this is where all PHP scripts are executed from (not from the original classes/ directory).
For each class decorated by other modules X-Cart creates an empty class having the same name, but with "Abstract" suffix. This class is the latest in the inheritance tree, so it inherits all methods and properties added by modules. And this class is then used in the rest of the source code instead of the original one (which becomes the top one in the inheritance tree for that class).