I have overriden the class Magento\Catalog\Block\Product\ProductList\Upsell
with my own Company\Base\Block\Product\ProductList\Upsell
.
The class Magento\Catalog\Block\Product\ProductList\Upsell
extends \Magento\Catalog\Block\Product\AbstractProduct
.
Now I have overridden \Magento\Catalog\Block\Product\AbstractProduct
with \Company\Base\Block\Product\AbstractProduct
and added a new method:
public function testAbstractMethod()
{
echo "test abstract works";
}
I added
<?php exit($this->testAbstractMethod()) ?>
to the template of the class Magento\Catalog\Block\Product\ProductList\Upsell
:
app\design\frontend\MyTheme\Base\Magento_Catalog\templates\product\list\items.phtml:
But I get:
Invalid method Company\Base\Block\Product\ProductList\Related\Interceptor::testAbstractMethod
But if I add the method testAbstractMethod() to the original core class \Magento\Catalog\Block\Product\AbstractProduct
then it works.
So it looks like only the first class is getting overriden and if this class extends another class which is overriden by dependency injection, then it wont work and load the original class?