I can not seem to override the Magento Invoice class.
I've created a module, installed it, enabled it. I have the following in my di.xml file
<?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\Sales\Model\Order\Pdf\Invoice" type="Dojo\InvoiceBarcodes\Model\Order\Pdf\Invoice" />
</config>
I've run the following commands:
./bin/magento cache:flush
./bin/magento setup:di:compile
If I run dev:di:info, it shows my class as a preference...
$ ./bin/magento dev:di:info "Magento\Sales\Model\Order\Pdf\Invoice"
DI configuration for the class Magento\Sales\Model\Order\Pdf\Invoice in the GLOBAL area
Preference: Dojo\InvoiceBarcodes\Model\Order\Pdf\Invoice
Constructor Parameters:
+-------------------+-----------------------------------------------------+-----------------------------------------------------------------------+
| Name | Requested Type | Configured Value |
I can verify it's not using my class because if I alter the Magento Invoice file, it reflects when I click print invoice.
I've checked all the logs, and there are no errors.
I'm not sure if I'm doing something wrong, if you can't override this class, or need to override in a different way.
Magento version 2.3.2
Any help would be appreciated.