I'm trying to implement a basic m2 class override following the M2 Fundamentals Course and it is not working. Here is what I have in my Training/Test/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Model\Product" type="Training\Test\Model\Testproduct" />
</config>
And inside the Training\Test\Model\Testproduct.php
<?php
namespace Training\Test\Model;
class Testproduct extends \Magento\Catalog\Model\Product
{
public function getPrice() {
return 3;
}
}
I understand it's better to do plugins / events, but my question is why is the above not working?
The module is installed and I also ran the following:
php bin/magento cache:flush
rm -Rf var/cache/*
rm -Rf var/di/
rm -Rf var/generation/*
rm -Rf var/page_cache/*
php bin/magento setup:di:compile
It also shows when runnning: php bin/magento module:status
List of enabled modules:
...
Training_Test