I am new to coding in Magento 2. I am trying to override a file using this guide https://webkul.com/blog/overriding-rewriting-classes-magento2/, and my file compiles without error, but changes don't take place on the frontend. I have put the file in a Hello World module called MyTest. My di.xml file located at app/code/[My_Vendor]/MyTest/etc/di.xml is
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Catalog\Pricing\Render\FinalPriceBox" type="[My_Vendor]\MyTest\Rewrite\Pricing\Render\FinalPriceBox" /> </config> and my FinalPriceBox.php file which overwrites vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php and is located at app/code/[My_Vendor]/MyTest/Rewrite/Pricing/Render/FinalPriceBox.php is
<?php namespace [My_Vendor]\MyTest\Rewrite\Pricing\Render; class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox { public function _renderAmountMinimal() { $id = $this->getPriceId() ? $this->getPriceId() : ‘product-minimal-price-’ . $this->getSaleableItem()->getId(); $amount = $this->minimalPriceCalculator->getAmount($this->getSaleableItem()); if ($amount === null) { return ‘’; } return $this->renderAmount( $amount, [ ‘display_label’ => __(‘As low as mytest’), ‘price_id’ => $id, ‘include_container’ => false, ‘skip_adjustments’ => true ] ); } } ?> I am not sure what is going wrong. I do not see any new error messages, and I know that changing the original file does cause the changes I want on the frontend. I also know that the module is enabled and correctly prints Hello World on a test page. The guide did not have a composer.json file so my module doesn't have one, and I am not sure if that could cause the problem. I was wondering if anyone had advice on what might be going wrong
Update:
I tried the two answers below, but for some reason it caused a page glitch as in the pictures below where the product names have been covered for anonymity.
Normal Page
Glitched Page
When I check the exception.log file I see 3 errors
"URL key for specified store already exists"
"Unable to retrive deployment version of static file from the file system"
and
"Reflection Exception Class[My_Vendor]\MyTest\Rewrite\Pricing\Render\FinalPriceBox does not exist at [My_Website_Folder]/vendor/magento/framework/Code/Reader/ClassReader.php"
I have tried looking up each of these errors, but so far the solutions haven't worked. I also tried running php bin/magento dev:di:info "[My_Vendor]\MyTest\Rewrite\Pricing\Render\FinalPriceBox" which shows the class as being configured.

